struts2-junit-plugin

Struts 2.3.14 junit test

こ雲淡風輕ζ 提交于 2021-02-07 14:13:01
问题 I'm using Struts 2.3.14 for my application... I need some unit test in my application... so I'm using junit4... but when I use ActionProxy in my test, it will show NullPointerException ... my test code is: ActionProxy proxy=getActionProxy("/customize/saveRewards"); SaveRewardsPlus rewards=(SaveRewardsPlus)proxy.getAction(); request.setParameter("list[0].img_id", "1"); request.setParameter("list[0].tag", "Test Tag"); request.setParameter("list[0].desc", "Test Desc"); String result=proxy

struts2 junit 2.3.12 plugin - unable to write successful test in struts2 junit4

非 Y 不嫁゛ 提交于 2020-01-13 05:53:31
问题 I'm using struts2 junit 2.3.12 plugin. If I run test directly, then I get : java.lang.NoClassDefFoundError: javax/servlet/ServletContext so I include <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> in my POM, after which I get : java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException so, I remove the above dependency and add

struts2 junit 2.3.12 plugin - unable to write successful test in struts2 junit4

假如想象 提交于 2020-01-13 05:53:30
问题 I'm using struts2 junit 2.3.12 plugin. If I run test directly, then I get : java.lang.NoClassDefFoundError: javax/servlet/ServletContext so I include <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> in my POM, after which I get : java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException so, I remove the above dependency and add

Struts2 Junit4 tests accumulate JSON responses with every action execution

与世无争的帅哥 提交于 2019-12-24 15:13:24
问题 I've written a few Junit4 tests, which looks like this : public class TestCampaignList extends StrutsJUnit4TestCase<Object> { public static final Logger LOG = Logger.getLogger(TestCampaignList.class.getName()); @Before public void loginAdmin() throws ServletException, UnsupportedEncodingException { request.setParameter("email", "nitin.cool4urchat@gmail.com"); request.setParameter("password", "22"); String response = executeAction("/login/admin"); System.out.println("Login Response : " +

Struts2.3.12 junit4 testcase request & session are null

≡放荡痞女 提交于 2019-12-18 07:05:05
问题 I have already gone through this solution : Struts 2 JUnit Plugin v2.2.3: Test Class Extending StrutsTestCase; 'request' is null But I'm already not having struts2-spring plugin, and neither I'm using spring in my application. I have 3 test-cases, 2 fails at request being null and one fails at session being null First Stacktrace java.lang.NullPointerException at org.apache.struts2.interceptor.MessageStoreInterceptor.before(MessageStoreInterceptor.java:228) at org.apache.struts2.interceptor

ActionContext.getContext().getParameters() returns null during StrutsJUnit4TestCase

廉价感情. 提交于 2019-12-10 18:58:34
问题 I am running a JUnit test via maven where a struts action java method is being tested that makes the following call: // Gets this from the "org.apache.struts2.util.TokenHelper" class in the struts2-core jar String token = TokenHelper.getTokenName(); Here is the method in "TokenHelper.java": /** * Gets the token name from the Parameters in the ServletActionContext * * @return the token name found in the params, or null if it could not be found */ public static String getTokenName() { Map

struts2 junit 2.3.12 plugin - unable to write successful test in struts2 junit4

倖福魔咒の 提交于 2019-12-04 15:43:44
I'm using struts2 junit 2.3.12 plugin. If I run test directly, then I get : java.lang.NoClassDefFoundError: javax/servlet/ServletContext so I include <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> in my POM, after which I get : java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException so, I remove the above dependency and add : <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-6.0</artifactId> <version>1

Struts2.3.12 junit4 testcase request & session are null

ⅰ亾dé卋堺 提交于 2019-11-29 12:07:15
I have already gone through this solution : Struts 2 JUnit Plugin v2.2.3: Test Class Extending StrutsTestCase; 'request' is null But I'm already not having struts2-spring plugin, and neither I'm using spring in my application. I have 3 test-cases, 2 fails at request being null and one fails at session being null First Stacktrace java.lang.NullPointerException at org.apache.struts2.interceptor.MessageStoreInterceptor.before(MessageStoreInterceptor.java:228) at org.apache.struts2.interceptor.MessageStoreInterceptor.intercept(MessageStoreInterceptor.java:193) at com.opensymphony.xwork2