http-headerswicketwicket-tester

How can I set http Header Data in WicketTester


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?


Solution

  • I see you use Wicket 1.4. In 1.5 there is org.apache.wicket.util.tester.BaseWicketTester.addRequestHeader(String, String).