This content has been marked as final.
Show 1 reply
-
1. Re: How to set cookie for Seam integration test
coldgin May 14, 2009 9:52 PM (in response to coldgin)Sorry to bump this one again, but does anyone know if setting a cookie for an integration test can be done? Inside the TestNG test case method, I am trying to do something like the following. I get a java.lang.UnsupportedOperationException on the getCookies().add(cookie) call. It also doesn't seem correct anyway to be setting cookies on the request. I am just trying to experiment with what is available on the FacesRequest. I tried grabbing the response object from ExternalContext, to add the cookie on the response, but that also doesn't work, or seem to be the correct approach:
... FacesRequest testPageRequest = new FacesRequest("/testPage.xhtml") { /** * This method simulates setting UI values */ @Override protected void updateModelValues() throws Exception { /** * Set cookie */ Cookie cookie = new Cookie("TEST_COOKIE","TEST COOKIE"); cookie.setDomain("mydomain.net"); cookie.setPath("/"); this.getCookies().add(cookie); //((HttpServletResponse)this.getFacesContext().getCurrentInstance().getExternalContext().getResponse()).addCookie(cookie); } ...
Thanks.