---------- 已转发邮件 ---------- 发件人: 覃洪军 <fshk...@gmail.com> 日期: 2012年4月3日 下午7:06 主题: Why doesn't StrutsJunit4TestCase invoke index() method 收件人: user-i...@struts.apache.org
---------- Forwarded message ---------- From: 覃洪军 <fshk...@gmail.com> Date: 2012/4/3 Subject: Why doesn't StrutsJunit4TestCase invoke index() method To: user-...@struts.apache.org Hi, I wrote a test for a web application with Struts2 REST, and got a error message: "java.lang.NoSuchMethodException: cn.fshk.stock.struts.biz.admin.AuthorizationController.execute()" Dose it suppose to invoke the index() method in a Struts2 REST controller? Can anyone give me some help? * The test class : package cn.fshk.stock2.struts; ... @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath*:application*.xml" }) @TransactionConfiguration(transactionManager = "transactionManager") public class TestStrutsBase<ActionName> extends StrutsSpringJUnit4TestCase<ActionName> { Logger logger = Logger.getLogger("cn.fshk"); @Test public void testStrutsUtil() throws UnsupportedEncodingException, ServletException { String result = executeAction("/biz/admin/authorization"); logger.debug(result); } } * The struts.xml fragment: ... <struts> <constant name="struts.convention.action.suffix" value="Controller" /> <constant name="struts.convention.action.mapAllMatches" value="true" /> <constant name="struts.convention.default.parent.package" value="rest-default" /> <constant name="struts.convention.package.locators" value="rest,struts,struts2,action,actions" /> <constant name="struts.convention.result.path" value="/" /> <constant name="struts.convention.action.packages" value="cn.fshk.stock.struts" /> <constant name="struts.action.extension" value="action,do,,xhtml,xml,json" /> <constant name="struts.mapper.class" value="org.apache.struts2.rest.RestActionMapper" /> </struts> * The struts.properties: struts.i18n.encoding=UTF-8 struts.objectFactory = spring struts.objectFactory.spring.autoWire = name struts.objectFactory.spring.useClassCache = true struts.multipart.parser=jakarta struts.multipart.saveDir= struts.multipart.maxSize=2097152 struts.serve.static=true struts.serve.static.browserCache=true struts.tag.altSyntax=true struts.devMode = true struts.i18n.reload=false struts.ui.theme=xhtml struts.ui.templateDir=template struts.ui.templateSuffix=ftl struts.configuration.xml.reload=false struts.url.http.port = 80 struts.url.https.port = 443 struts.custom.i18n.resources=globalmessages struts.dispatcher.parametersWorkaround = false struts.freemarker.wrapper.altMap=true struts.xslt.nocache=false --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org