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 2014/04/26 07:03:56 UTC
[3/3] git commit: Updates tests as using Object's methods is
prohibited
Updates tests as using Object's methods is prohibited
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5d8aa8a8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5d8aa8a8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5d8aa8a8
Branch: refs/heads/feature/exclude-object-class
Commit: 5d8aa8a80be131dbcf412c28aec0435d3bdc23e3
Parents: bcc0327
Author: Lukasz Lenart <lu...@apache.org>
Authored: Sat Apr 26 06:59:18 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Sat Apr 26 06:59:18 2014 +0200
----------------------------------------------------------------------
.../ExecuteAndWaitInterceptorTest.java | 2 ++
.../struts2/views/jsp/PropertyTagTest.java | 30 ++++++++++++--------
.../apache/struts2/views/jsp/ui/SelectTest.java | 2 +-
.../struts2/rest/RestActionInvocationTest.java | 2 ++
.../xwork2/DefaultActionInvocationTest.java | 8 ++++++
5 files changed, 31 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/5d8aa8a8/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
index 01d1a6e..5a01015 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
@@ -32,6 +32,7 @@ import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
import com.opensymphony.xwork2.mock.MockResult;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsInternalTestCase;
@@ -222,6 +223,7 @@ public class ExecuteAndWaitInterceptorTest extends StrutsInternalTestCase {
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
builder.factory(ObjectFactory.class);
builder.factory(ActionProxyFactory.class, DefaultActionProxyFactory.class);
+ builder.factory(OgnlUtil.class, OgnlUtil.class);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/5d8aa8a8/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java
index cce9a0c..a2b77ba 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java
@@ -180,11 +180,13 @@ public class PropertyTagTest extends StrutsInternalTestCase {
pageContext.setRequest(request);
// test
- {PropertyTag tag = new PropertyTag();
- tag.setPageContext(pageContext);
- tag.setValue("%{toString()}");
- tag.doStartTag();
- tag.doEndTag();}
+ {
+ PropertyTag tag = new PropertyTag();
+ tag.setPageContext(pageContext);
+ tag.setValue("%{formatTitle()}");
+ tag.doStartTag();
+ tag.doEndTag();
+ }
// verify test
request.verify();
@@ -212,7 +214,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
tag.setEscape(false);
tag.setEscapeJavaScript(true);
tag.setPageContext(pageContext);
- tag.setValue("%{toString()}");
+ tag.setValue("%{formatTitle()}");
tag.doStartTag();
tag.doEndTag();}
@@ -242,7 +244,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
tag.setEscape(false);
tag.setEscapeXml(true);
tag.setPageContext(pageContext);
- tag.setValue("%{toString()}");
+ tag.setValue("%{formatTitle()}");
tag.doStartTag();
tag.doEndTag();}
@@ -272,7 +274,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
tag.setEscape(false);
tag.setEscapeCsv(true);
tag.setPageContext(pageContext);
- tag.setValue("%{toString()}");
+ tag.setValue("%{formatTitle()}");
tag.doStartTag();
tag.doEndTag();}
@@ -300,7 +302,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
// test
{PropertyTag tag = new PropertyTag();
tag.setPageContext(pageContext);
- tag.setValue("toString()");
+ tag.setValue("formatTitle()");
tag.doStartTag();
tag.doEndTag();}
@@ -328,7 +330,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
// test
{PropertyTag tag = new PropertyTag();
tag.setPageContext(pageContext);
- tag.setValue("toString()");
+ tag.setValue("formatTitle()");
tag.doStartTag();
tag.doEndTag();}
@@ -356,7 +358,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
// test
{PropertyTag tag = new PropertyTag();
tag.setPageContext(pageContext);
- tag.setValue("%{toString()}");
+ tag.setValue("%{formatTitle()}");
tag.doStartTag();
tag.doEndTag();}
@@ -385,8 +387,12 @@ public class PropertyTagTest extends StrutsInternalTestCase {
return title;
}
- public String toString() {
+ public String formatTitle() {
return "Foo is: " + title;
}
+
+ public String toString() {
+ return formatTitle();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/5d8aa8a8/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
index 094cfc9..06b7e80 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java
@@ -494,7 +494,7 @@ public class SelectTest extends AbstractUITagTest {
tag.setList("list2");
tag.setListKey("id");
tag.setListValue("name");
- tag.setValue("fooInt.toString()");
+ tag.setValue("fooInt");
// header stuff
tag.setHeaderKey("headerKey");
http://git-wip-us.apache.org/repos/asf/struts/blob/5d8aa8a8/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionInvocationTest.java
----------------------------------------------------------------------
diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionInvocationTest.java b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionInvocationTest.java
index af2a7fd..6db05f1 100644
--- a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionInvocationTest.java
+++ b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionInvocationTest.java
@@ -10,6 +10,7 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.mock.MockActionProxy;
import com.opensymphony.xwork2.mock.MockInterceptor;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
import junit.framework.TestCase;
import org.apache.struts2.ServletActionContext;
@@ -228,6 +229,7 @@ public class RestActionInvocationTest extends TestCase {
request.setMethod("GET");
+ restActionInvocation.setOgnlUtil(new OgnlUtil());
restActionInvocation.invoke();
assertEquals(123, response.getStatus());
http://git-wip-us.apache.org/repos/asf/struts/blob/5d8aa8a8/xwork-core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
index 1b93a5c..e0aa8ba 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
@@ -1,9 +1,14 @@
package com.opensymphony.xwork2;
+import com.mockobjects.dynamic.Mock;
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
import com.opensymphony.xwork2.mock.MockActionProxy;
import com.opensymphony.xwork2.mock.MockContainer;
import com.opensymphony.xwork2.mock.MockInterceptor;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import java.util.ArrayList;
import java.util.HashMap;
@@ -39,6 +44,9 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
mockInterceptor3.setExpectedFoo("test3");
DefaultActionInvocation defaultActionInvocation = new DefaultActionInvocationTester(interceptorMappings);
+ container.inject(defaultActionInvocation);
+ defaultActionInvocation.stack = container.getInstance(ValueStackFactory.class).createValueStack();
+
defaultActionInvocation.invoke();
assertTrue(mockInterceptor1.isExecuted());
assertTrue(mockInterceptor2.isExecuted());