struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [4/4] struts-site git commit: Updates production by Jenkins
Date Wed, 23 Aug 2017 11:43:45 GMT
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/e8baeb93
Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/e8baeb93
Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/e8baeb93

Branch: refs/heads/asf-site
Commit: e8baeb931e48f7cd360160b6923af48d534886f4
Parents: c4f3bdc
Author: jenkins <builds@apache.org>
Authored: Wed Aug 23 11:43:40 2017 +0000
Committer: jenkins <builds@apache.org>
Committed: Wed Aug 23 11:43:40 2017 +0000

----------------------------------------------------------------------
 content/core-developers/index.html    |   2 +-
 content/plugins/convention/index.html |   3 +-
 content/plugins/index.html            |   1 +
 content/plugins/junit/index.html      | 327 +++++++++++++++++++++++++++++
 4 files changed, 330 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-site/blob/e8baeb93/content/core-developers/index.html
----------------------------------------------------------------------
diff --git a/content/core-developers/index.html b/content/core-developers/index.html
index f8a2c41..20ab91c 100644
--- a/content/core-developers/index.html
+++ b/content/core-developers/index.html
@@ -164,7 +164,7 @@ Each may be configured via XML or annotations.</p>
   <li><a href="application-servers.html">Application Servers</a></li>
   <li><a href="performance-tuning.html">Performance Tuning</a></li>
   <li><a href="../security/">Security</a></li>
-  <li>[Testing Actions] - export https://cwiki.apache.org/confluence/display/WW/Testing+Actions
+  <li><a href="../plugins/junit/">Testing Actions</a>
     <ul>
       <li><a href="https://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/">(arsenalist)</a></li>
       <li><a href="http://fassisrosa.blogspot.com/2006/11/unit-testing-struts-20\.html">(rosa)</a></li>

http://git-wip-us.apache.org/repos/asf/struts-site/blob/e8baeb93/content/plugins/convention/index.html
----------------------------------------------------------------------
diff --git a/content/plugins/convention/index.html b/content/plugins/convention/index.html
index d3dff08..e1c7631 100644
--- a/content/plugins/convention/index.html
+++ b/content/plugins/convention/index.html
@@ -124,10 +124,9 @@
 <article class="container">
   <section class="col-md-12">
     <a href="../" title="back to Plugins"><< back to Plugins</a>
+    [Edit on GitHub](https://github.com/apache/struts-site/edit/master/source/plugins/convention/index.md){:
.edit-on-gh title="Edit this page on GitHub"}
     <h1 class="no_toc" id="convention-plugin">Convention Plugin</h1>
 
-<p><a href="https://github.com/apache/struts-site/edit/master/source/plugins/convention/index.md"
class="edit-on-gh" title="Edit this page on GitHub">Edit on GitHub</a></p>
-
 <ul id="markdown-toc">
   <li><a href="#introduction" id="markdown-toc-introduction">Introduction</a></li>
   <li><a href="#setup" id="markdown-toc-setup">Setup</a></li>

http://git-wip-us.apache.org/repos/asf/struts-site/blob/e8baeb93/content/plugins/index.html
----------------------------------------------------------------------
diff --git a/content/plugins/index.html b/content/plugins/index.html
index e7e8d1d..4872474 100644
--- a/content/plugins/index.html
+++ b/content/plugins/index.html
@@ -127,6 +127,7 @@
 
 <ul>
   <li><a href="convention/">Convention plugin</a></li>
+  <li><a href="junit/">JUnit plugin</a></li>
 </ul>
 
 

http://git-wip-us.apache.org/repos/asf/struts-site/blob/e8baeb93/content/plugins/junit/index.html
----------------------------------------------------------------------
diff --git a/content/plugins/junit/index.html b/content/plugins/junit/index.html
new file mode 100644
index 0000000..b0fd087
--- /dev/null
+++ b/content/plugins/junit/index.html
@@ -0,0 +1,327 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8"/>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+  <meta name="Date-Revision-yyyymmdd" content="20140918"/>
+  <meta http-equiv="Content-Language" content="en"/>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+
+  <title>Convention plugin</title>
+
+  <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic"
rel="stylesheet" type="text/css">
+  <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/main.css" rel="stylesheet">
+  <link href="/css/custom.css" rel="stylesheet">
+  <link href="/highlighter/github-theme.css" rel="stylesheet">
+
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+  <script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
+  <script type="text/javascript" src="/js/community.js"></script>
+</head>
+<body>
+
+<a href="http://github.com/apache/struts" class="github-ribbon">
+  <img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"
alt="Fork me on GitHub">
+</a>
+
+<header>
+  <nav>
+    <div role="navigation" class="navbar navbar-default navbar-fixed-top">
+      <div class="container">
+        <div class="navbar-header">
+          <button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle">
+            Menu
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a>
+        </div>
+        <div id="struts-menu" class="navbar-collapse collapse">
+          <ul class="nav navbar-nav">
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Home<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/index.html">Welcome</a></li>
+                <li><a href="/downloads.html">Downloads</a></li>
+                <li><a href="/announce.html">Announcements</a></li>
+                <li><a href="http://www.apache.org/licenses/">License</a></li>
+                <li><a href="http://apache.org/foundation/thanks.html">Thanks!</a></li>
+                <li><a href="http://apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Support<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/mail.html">User Mailing List</a></li>
+                <li><a href="https://issues.apache.org/jira/browse/WW">Issue
Tracker</a></li>
+                <li><a href="/security.html">Reporting Security Issues</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/project-info.html">Project info</a></li>
+                <li><a href="/maven/struts2-core/dependencies.html">Struts Core
dependencies</a></li>
+                <li><a href="/maven/struts2-plugins/modules.html">Plugin dependencies</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Documentation<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/birdseye.html">Birds Eye</a></li>
+                <li><a href="/primer.html">Key Technologies</a></li>
+                <li><a href="/kickstart.html">Kickstart FAQ</a></li>
+                <li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li>
+                <li class="divider"></li>
+                <li><a href="/getting-started/">Getting Started</a></li>
+                <li><a href="/security/">Security Guide</a></li>
+                <li><a href="/docs/tutorials.html">Tutorials</a></li>
+                <li><a href="/docs/faqs.html">FAQs</a></li>
+                <li><a href="/docs/guides.html">Guides</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/struts2-core/apidocs/index.html">Struts Core
API</a></li>
+                <li><a href="/docs/plugins.html">Plugin APIs</a></li>
+                <li><a href="/docs/tag-reference.html">Tag reference</a></li>
+                <li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin
registry</a></li>
+                <li class="divider"></li>                
+                <li><a href="/core-developers/">Core Developers Guide (WIP)</a></li>
+                <li><a href="/plugins/">Plugins (WIP)</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Contributing<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/youatstruts.html">You at Struts</a></li>
+                <li><a href="/helping.html">How to Help FAQ</a></li>
+                <li><a href="/dev-mail.html">Development Lists</a></li>
+                <li class="divider"></li>
+                <li><a href="/submitting-patches.html">Submitting patches</a></li>
+                <li><a href="/builds.html">Source Code</a></li>
+                <li><a href="/coding-standards.html">Coding standards</a></li>
+                <li class="divider"></li>
+                <li><a href="/releases.html">Release Guidelines</a></li>
+                <li><a href="/bylaws.html">PMC Charter</a></li>
+                <li><a href="/volunteers.html">Volunteers</a></li>
+                <li><a href="https://git-wip-us.apache.org/repos/asf?p=struts.git">Source
Repository</a></li>
+              </ul>
+            </li>
+            <li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+  </nav>
+</header>
+
+
+<article class="container">
+  <section class="col-md-12">
+    <a href="../" title="back to Plugins"><< back to Plugins</a>
+    [Edit on GitHub](https://github.com/apache/struts-site/edit/master/source/plugins/junit/index.md){:
.edit-on-gh title="Edit this page on GitHub"}
+    <h1 class="no_toc" id="junit-plugin">JUnit plugin</h1>
+
+<ul id="markdown-toc">
+  <li><a href="#struts-actions-without-spring" id="markdown-toc-struts-actions-without-spring">Struts
actions (without Spring)</a></li>
+  <li><a href="#the-template" id="markdown-toc-the-template">The template</a></li>
+  <li><a href="#struts-actions-using-spring" id="markdown-toc-struts-actions-using-spring">Struts
Actions using Spring</a></li>
+</ul>
+
+<p>The recommended way to test actions is to instantiate the action classes and test
them. The <em>JUnit Plugin</em>  supports 
+testing actions within a Struts invocation, meaning that a full request is simulated, and
the output of the action can 
+be tested.</p>
+
+<h2 id="struts-actions-without-spring">Struts actions (without Spring)</h2>
+
+<p>To test actions that do not use Spring, extend <code class="highlighter-rouge">StrutsTestCase</code>.
The following example shows different ways of testing 
+an action:</p>
+
+<ul>
+  <li>Mapping:
+```xml
+    <struts>
+    <constant name="struts.objectFactory" value="spring" />
+    <package name="test" namespace="/test" extends="struts-default">
+        <action name="testAction" class="org.apache.struts2.TestAction">
+            <result type="freemarker">/template.ftl</result>
+        </action>
+    </package>
+</struts>
+    <p>```</p>
+  </li>
+  <li>
+    <p>Action:
+```java<br />
+public class TestAction extends ActionSupport {
+    private String name;</p>
+
+    <div class="highlighter-rouge"><pre class="highlight"><code>public
String getName() {
+    return name;
+}
+  
+public void setName(String name) {
+    this.name = name;
+} } ```
+</code></pre>
+    </div>
+  </li>
+  <li>
+    <p>JUnit:
+```java
+package org.apache.struts2;</p>
+
+    <p>import org.apache.struts2.dispatcher.mapper.ActionMapping;</p>
+
+    <p>import java.util.HashMap;
+import java.io.UnsupportedEncodingException;</p>
+
+    <p>import com.opensymphony.xwork2.ActionProxy;
+import com.opensymphony.xwork2.Action;</p>
+
+    <p>import javax.servlet.ServletException;</p>
+
+    <p>public class StrutsTestCaseTest extends StrutsTestCase {
+    public void testGetActionMapping() {
+        ActionMapping mapping = getActionMapping(“/test/testAction.action”);
+        assertNotNull(mapping);
+        assertEquals(“/test”, mapping.getNamespace());
+        assertEquals(“testAction”, mapping.getName());
+    }</p>
+
+    <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");
+    String name = (String) findValueAfterExecute("name");
+    assertEquals("FD", name);
+} } ```
+</code></pre>
+    </div>
+  </li>
+</ul>
+
+<h2 id="the-template">The template</h2>
+
+<p>If you use JSPs as the template engine you won’t be able to test the action output
outside the container. 
+The <a href="../embeddedjsp/">Embedded JSP Plugin</a> can be used to overcome
this limitation and be able to use JSPs from 
+the classpath and outside the container.</p>
+
+<p>There are several utility methods and mock objects defined in StrutsTestCase which
can be used to facilitate the testing:</p>
+
+<ul>
+  <li>Methods:
+|Method Name|Description|
+|———–|———–|
+|executeAction(String)|Pass the url for the action, and it will return the output of the
action. This output <strong>is not</strong> the action result, like “success”,
but what would be written to the result stream. To use this the actions must be using a result
type that can be read from the classpath, like FreeMarker, velocity, etc (if you are using
the experimental Embedded JSP Plugin, you can use JSPs also)|
+|getActionProxy(String)|Builds an action proxy that can be used to invoke an action, by calling
execute() on the returned proxy object. The return value of execute() is the action result,
like “success”|
+|getActionMapping(String)|Gets an ActionMapping for the url|
+|injectStrutsDependencies(object)|Injects Struts dependencies into an object (dependencies
are marked with Inject)|
+|findValueAfterExecute(String)|Finds an object in the value stack, after an action has been
executed|
+|applyAdditionalParams(ActionContext)|Can be overwritten in subclass to provide additional
params and settings used during action invocation|
+|createAction(Class)|Can be used to instantiate an action which requires framework’s dependencies
to be injected (e.g. extending ActionSupport requires inject some internal dependencies)|</li>
+  <li>Fields:
+|Field|Description|
+|—–|———–|
+|MockHttpServletRequest request|The request that will be passed to Struts. Make sure to set
parameters in this object before calling methods like getActionProxy|
+|MockHttpServletResponse response|The response object passed to Struts, you can use this
class to test the output, response headers, etc|
+|MockServletContext servletContext|The servlet context object passed to Struts|</li>
+</ul>
+
+<h2 id="struts-actions-using-spring">Struts Actions using Spring</h2>
+
+<p>Make sure to add a dependency to the <a href="../spring/">Spring Plugin</a>
to your <code class="highlighter-rouge">pom.xml</code>:</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;dependency&gt;</span>
+    <span class="nt">&lt;groupId&gt;</span>org.apache.struts<span
class="nt">&lt;/groupId&gt;</span>
+    <span class="nt">&lt;artifactId&gt;</span>struts2-spring-plugin<span
class="nt">&lt;/artifactId&gt;</span>
+    <span class="nt">&lt;version&gt;</span>STRUTS_VERSION<span class="nt">&lt;/version&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</code></pre>
+</div>
+
+<p>If you use Spring as the object factory, the <code class="highlighter-rouge">StrutsSpringTestCase</code>
class can be used to write your JUnits. This class 
+extends <code class="highlighter-rouge">StrutsTestCase</code> and has an <code
class="highlighter-rouge">applicationContext</code> field of type <code class="highlighter-rouge">ApplicationContext</code>.</p>
+
+<p>The Spring context is loaded from <code class="highlighter-rouge">classpath\*:applicationContext.xml</code>
by default. To provide a different location, 
+overwrite <code class="highlighter-rouge">getContextLocations</code>.</p>
+
+  </section>
+</article>
+
+
+<footer class="container">
+  <div class="col-md-12">
+    Copyright &copy; 2000-2016 <a href="http://www.apache.org/">The Apache Software
Foundation </a>.
+    All Rights Reserved.
+  </div>
+  <div class="col-md-12">
+    Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project
logos are
+    trademarks of The Apache Software Foundation.
+  </div>
+  <div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div>
+</footer>
+
+<script>!function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (!d.getElementById(id)) {
+    js = d.createElement(s);
+    js.id = id;
+    js.src = "//platform.twitter.com/widgets.js";
+    fjs.parentNode.insertBefore(js, fjs);
+  }
+}(document, "script", "twitter-wjs");</script>
+<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
+
+<div id="fb-root"></div>
+
+<script>(function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (d.getElementById(id)) return;
+  js = d.createElement(s);
+  js.id = id;
+  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
+  fjs.parentNode.insertBefore(js, fjs);
+}(document, 'script', 'facebook-jssdk'));</script>
+
+
+<script>
+$(function() {
+  return $("h2, h3, h4, h5, h6").each(function(i, el) {
+    var $el, id;
+    $el = $(el);
+    id = $el.attr('id');
+    if (id) {
+      $el.removeAttr('id');
+      return $el.before($("<a />").addClass('anchor').attr('name', id));
+    }
+  });
+});
+</script>
+
+</body>
+</html>


Mime
View raw message