如何在 WicketTester 中设置 http 标头数据
我有一个位于代理后面的网络应用程序。如果用户已登录,则会设置 http 标头。我有一个页面检查标头,以确保用户未登录。如何将标头添加到 WicketTester 生成的 MockHttpRequest
中?
我当前的单元测试如下所示:
public void testLoggedinViaProxy()
{
wt.destroy();
wt = new WicketTester(new AbstractApplicationHelper());
wt.setupRequestAndResponse();
wt.getServletRequest().addHeader("myheader", "someValue");
wt.createRequestCycle();
cl=(CSSDLogin)wt.startPage(CSSDLogin.class);
wt.assertRenderedPage(AppBasePageHelper.class);
}
更新:我在生产网站中使用 1.4.17。在候选版本/里程碑阶段完全发布之前,我不打算升级到 1.5.X。
对 wt.setupRequestAndResponse(); 的调用是对 Wicket-1215 我从 你如何设置使用 Wicket 进行单元测试时的自定义会话?
I have web application that is behind a proxy. If the user has logged in, an http-header is set. I have a page that checks the header, to make sure the user isn't logged in. How can I add the header to the MockHttpRequest
generated by WicketTester?
My current unit test looks like the following:
public void testLoggedinViaProxy()
{
wt.destroy();
wt = new WicketTester(new AbstractApplicationHelper());
wt.setupRequestAndResponse();
wt.getServletRequest().addHeader("myheader", "someValue");
wt.createRequestCycle();
cl=(CSSDLogin)wt.startPage(CSSDLogin.class);
wt.assertRenderedPage(AppBasePageHelper.class);
}
UPDATE: I'm using 1.4.17 in a production website. I don't intend on upgrading to 1.5.X until it's a full release out of the Release Candidate/Milestone Stages.
the call to wt.setupRequestAndResponse();
was an attempted fix for Wicket-1215
which I found from How Do you Set A Custom Session when unit-testing with-Wicket?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到您使用 Wicket 1.4。 1.5 中有 org.apache.wicket.util.tester.BaseWicketTester.addRequestHeader(String, String)。
I see you use Wicket 1.4. In 1.5 there is org.apache.wicket.util.tester.BaseWicketTester.addRequestHeader(String, String).