[英]Tapestry page junit test
I try to write a junit test for tapestry 5.4 page rendering: 我尝试为挂毯 5.4页面渲染编写一个junit测试:
import org.apache.tapestry5.test.PageTester;
public class LoadTest {
private final String PAGE_NAME = "Login";
private final String APP_NAME = "";
private final String context = "src/main/webapp";
private PageTester tester;
@Before
public void init() {
String appPackage = "hu.webapp";
tester = new PageTester(appPackage, APP_NAME, context, AppModule.class);
}
@Test
public void confirmIndexIsLoaded() {
Document document = new Document();
document = tester.renderPage(PAGE_NAME);
assertNotNull(document);
}
}
But I got an RuntimeException
, and it said Request was not handled: 'Login' may not be a valid page name.
但是我遇到了
RuntimeException
,它说Request was not handled: 'Login' may not be a valid page name.
But this is a working page in my webapp, and it renders well. 但这是我的webapp中的工作页面,并且呈现效果很好。
Have somebody any idea(s) what's wrong with test or can somebody shows me a similar working test code? 有人知道测试有什么问题吗,或者有人可以向我展示类似的工作测试代码?
Thanks in advance! 提前致谢!
Generally speaking, this only happens when you inform the wrong package
for your page's package. 一般来说,只有在您为页面的软件包通知了错误的
package
时,才会发生这种情况。 Take a look (it works for me): 看看(它对我有用):
import org.apache.tapestry5.test.PageTester;
public class LoadTest {
private final String PAGE_NAME = "Login"; // It has to be right too!
private final String APP_NAME = "app"; // Where was your app name?
private final String context = "src/main/webapp"; // Is that path right in your project?
private PageTester tester;
@Before
public void init() {
String appPackage = "hu.webapp"; // Check if that's really correct!!!
tester = new PageTester(appPackage, APP_NAME, context);
}
@Test
public void confirmIndexIsLoaded() {
Document document = tester.renderPage(PAGE_NAME);
assertNotNull(document);
}
}
Also, check your app
name, it should have been configured at your web.xml as the Tapestry filter, like in, eg: 另外,检查您的
app
名称,它应该已经在web.xml中配置为Tapestry过滤器,例如:
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.