StrutsTestCase 2.1.4 中缺少配置资源
我正在尝试使用 StrutsTestCase 2.1.4 对我的 Struts 应用程序进行单元测试。但是当我尝试运行测试时,出现“路径 /WEB-INF/web.xml 缺少配置资源”错误。
我在 StrutsTestCase 的常见问题解答中查找了它,并按照说明将我的应用程序路径添加到类路径中。然而,这并没有奏效。
然后我使用setConfigFile()方法指定web.xml和struts-config.xml的路径。如您所见,它也不起作用。
这是我的测试类中的 setUp() 方法重写:
public void setUp() throws Exception {
super.setUp();
File web = new File("E:/JavaPros/stolon/STOLONCAS/web/");
this.setContextDirectory(web);
this.setConfigFile("E:/JavaPros/stolon/STOLONCAS/web/WEB-INF/web.xml");
this.setConfigFile("E:/JavaPros/stolon/STOLONCAS/web/WEB-INF/struts-config.xml");
}
使用此方法的不同之处在于错误消息变为“缺少路径 E:/JavaPros/stolon/STOLONCAS/build/web/WEB-INF/struts-config 的配置资源” .xml”。这让我非常困惑,因为我绝对确定该路径中有 struts-config.xml 。
I'm trying to use StrutsTestCase 2.1.4 to do unit testing on my Struts application. But when I tried to run the test, a "missing configuration resources for path /WEB-INF/web.xml" error happens.
I looked it up in the FAQ of StrutsTestCase, and followed the instruction to add my application path to the classpath. However, it didn't work.
Then I use the setConfigFile() method to specify the path of web.xml and struts-config.xml. As you see, it didn't work, either.
Here's the setUp() method override in my test class:
public void setUp() throws Exception {
super.setUp();
File web = new File("E:/JavaPros/stolon/STOLONCAS/web/");
this.setContextDirectory(web);
this.setConfigFile("E:/JavaPros/stolon/STOLONCAS/web/WEB-INF/web.xml");
this.setConfigFile("E:/JavaPros/stolon/STOLONCAS/web/WEB-INF/struts-config.xml");
}
One thing different by using this method is the error msg became "Missing configuration resource for path E:/JavaPros/stolon/STOLONCAS/build/web/WEB-INF/struts-config.xml". This makes me very confused for I'm absolutely sure that there is the struts-config.xml in that path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论