Java Can';不要让junit使用Struts2约定插件、注释、平铺和Maven
我正在使用Struts2约定插件以及瓷砖和注释,并且正在使用Maven构建项目。我在让junit成功运行时遇到问题。根错误消息似乎是错误的Java Can';不要让junit使用Struts2约定插件、注释、平铺和Maven,java,maven,junit,struts2,annotations,Java,Maven,Junit,Struts2,Annotations,我正在使用Struts2约定插件以及瓷砖和注释,并且正在使用Maven构建项目。我在让junit成功运行时遇到问题。根错误消息似乎是错误的 Caused by: The Result type [tiles] which is defined in the Result annotation on the class [class com.mycompany.myproject.web.actions.security.ResendConfirmationAction] or determine
Caused by: The Result type [tiles] which is defined in the Result annotation on the class [class com.mycompany.myproject.web.actions.security.ResendConfirmationAction] or determined by the file extension or is the default result type for the PackageConfig of the action, could not be found as a result-type defined for the Struts/XWork package [com.dr_dee_sw.campaigner.web.actions.security#convention-default#/security] - [unknown location]
at org.apache.struts2.convention.DefaultResultMapBuilder.createResultConfig(DefaultResultMapBuilder.java:450)
我的所有Struts2操作都会出现此错误,而不仅仅是列出的操作
下面是重新确认
@Results({ @Result(name = "success", type = "tiles", location = "resend-confirmation"),
@Result(name = "input", type = "tiles", location = "resend-confirmation") })
public class ResendConfirmationAction extends ActionSupport
{
...
}
我的struts.xml文件如下:
<struts>
<constant name="struts.custom.i18n.resources" value="campaigner_messages" />
<constant name="struts.convention.action.includeJars" value=".*?/campaigner.*?jar(!/)?,.*?/dr-dee-commons-1.0.*?jar(!/)?"/>
<constant name="struts.convention.action.fileProtocols" value="file,jar,zip"/>
<constant name="struts.convention.default.parent.package" value="convention-tiles5"/>
<constant name="struts.convention.result.path" value="/"/>
<constant name="struts.devMode" value="true" />
<package name="convention-tiles5" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
</package>
</struts>
public class ResendConfirmationActionTestCase extends AbstractStrutsSpringTestCase
{
@Test
public void testSuccess() throws Exception
{
ActionProxy proxy = getActionProxy("/security/resend-confirmation");
ResendConfirmationAction action = (ResendConfirmationAction)proxy.getAction();
// Setup
request.setParameter("accountReason", "Bruce");
request.setParameter("clearTextPassword", "test");
request.setParameter("email", "test");
request.setParameter("firstName", "test");
request.setParameter("lastName", "test");
proxy.setExecuteResult(false);
// Execute
String result = proxy.execute();
// Test Results
assertTrue(action.getFieldErrors().size() == 0);
assertEquals(Action.SUCCESS, result);
}
}
我遗漏了什么?您在哪里使用junit?如果您在服务器上运行junit,它会工作吗?我将junit用作Maven构建过程的一部分。所以,在这个例子中,我尝试运行ResendConfirmationTestCase。我将把它添加到描述中。是的,在Wildfly 8上运行时实际的代码是有效的。
WEB-INF
inresources
看起来很奇怪。)尝试一下src/main/resources
或test
。