Hi seam team,
I first want to say thanks for all the work you've done until now. It's really good to work with a framework like this one, and specially with all the functions that are available.
I'm currently developing a web app and while I'm doing the integration tests, I need to give special URLs to my application to be able to test a specific business logic (the site has different behaviors upon the incoming URL)
For this I'm using a NonFacesRequest() test giving a site url into the constructor but then when I'm resolving the siteUrl (from the seam component) I always get the same URL:
http://localhost:8080/myproject/page.seam
Here is the code of my seam component:
@Factory("siteUrl") public void resolveURL() { HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); try { siteUrl = new URL(request.getRequestURL().toString()); } catch (MalformedURLException e) { FacesMessages.instance().add("Malformed URL for site"); log.error("Malformed URL for site."); } }
After searching a bit in the seam code, I've seen that the MockHttpServletRequest has the getRequestURI() method hardcoded.
public String getRequestURI() { return "http://localhost:8080/myproject/page.seam"; }
So, I'm wondering if it's better if I use my own Mock class, or it you can improve the default one to allow us putting different URLs?
Cheers,
/Benoit
I'd say that this is exactly where you'd want to use your own mock ServletRequest. Unfortunately, there currently isn't an easy way to get SeamTest to use your mock. There will be in Seam 2.1, though (jira issue).