I am not able to fetch a proxy to struts action in JUnit test case using StrutsTestCase

ساخت وبلاگ

Vote count: 0

I am trying to write JUnit test cases for an application written in Struts2. I am trying to follow the process given in these 2 links :

https://struts.apache.org/docs/testing-actions.html

https://glindholm.wordpress.com/2008/06/30/unit-testing-struts-2-actions/

I am using mockrunner-servlet.jar, struts2-junit-plugin-2.3.15.jar, junit-4.8.2.jar apart from many other jars.

Basically the problem that I am facing is at these 2 places in both the approaches :

ActionProxy proxy = getActionProxy("/<namespace>/<action-name>");

and

dispatcher.getContainer() .getInstance(ActionProxyFactory.class) .createActionProxy( namespace, actionName, null, true, // execute result false);

The exception I'm getting is :

There is no Action mapped for action name <action-name>. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)

... ...

Basically I suspect that while creating proxy, it is not able to location struts.xml. The struts.xml is located in src folder. src/struts.xml

Also in struts.xml, we have included various xml files which contain the action-mappings for struts2.

struts.xml
<struts>
<constant name="struts.devMode" value="true"/>
<include file="/strutsConfig/module1/module-struts-config.xml"></include>
...
...
</struts>

I also tried to use this solution, which I found at one of the links, but still not able to resolve it.

@Override
protected String getConfigPath() {
return "struts.xml";
}

Please help me resolve this such that proxy object is created.

asked 39 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : i am not your guru,i am not alone,i am not a serial killer,i am not a crook,i am not alone lyrics,i am not alone chords,i am not a robot,i am not a serial killer movie,i am not my hair,i am not a human being, نویسنده : استخدام کار backsoft بازدید : 310 تاريخ : پنجشنبه 25 شهريور 1395 ساعت: 1:10