You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/11/21 06:57:41 UTC
[2/2] struts git commit: WW-4716 Allows create actions with all
dependencies injected
WW-4716 Allows create actions with all dependencies injected
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6f7fcaa3
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6f7fcaa3
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6f7fcaa3
Branch: refs/heads/master
Commit: 6f7fcaa338672cb391a307cd1f199606423822e9
Parents: 321d9da
Author: Lukasz Lenart <lu...@apache.org>
Authored: Sun Nov 20 18:10:03 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Sun Nov 20 18:10:03 2016 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/struts2/StrutsTestCase.java | 9 +++++++++
.../src/main/java/org/apache/struts2/StrutsTestCase.java | 9 +++++++++
2 files changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/6f7fcaa3/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
----------------------------------------------------------------------
diff --git a/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java b/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
index 6e21bf4..7a36ab9 100644
--- a/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
+++ b/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
@@ -152,6 +152,15 @@ public abstract class StrutsTestCase extends XWorkTestCase {
return proxy;
}
+ /**
+ * A helper method which allows instantiate an action if this action extends
+ * {@link com.opensymphony.xwork2.ActionSupport} or any other action class
+ * that requires framework's dependencies injection.
+ */
+ protected <T> T createAction(Class<T> clazz) {
+ return container.inject(clazz);
+ }
+
protected void initActionContext(ActionContext actionContext) {
actionContext.setParameters(HttpParameters.create(request.getParameterMap()).build());
initSession(actionContext);
http://git-wip-us.apache.org/repos/asf/struts/blob/6f7fcaa3/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
----------------------------------------------------------------------
diff --git a/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java b/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
index 9a2b5f7..5ff3de0 100644
--- a/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
+++ b/plugins/testng/src/main/java/org/apache/struts2/StrutsTestCase.java
@@ -51,6 +51,15 @@ public class StrutsTestCase extends TestNGXWorkTestCase {
return du;
}
+ /**
+ * A helper method which allows instantiate an action if this action extends
+ * {@link com.opensymphony.xwork2.ActionSupport} or any other action class
+ * that requires framework's dependencies injection.
+ */
+ protected <T> T createAction(Class<T> clazz) {
+ return container.inject(clazz);
+ }
+
@AfterTest
protected void tearDown() throws Exception {
super.tearDown();