-
1. Re: How long till JSFUnit (richfaces) supports redirect?
ssilvert Apr 2, 2008 7:52 AM (in response to kragoth)Right now I'm in the middle of a major restructuring effort of the JSFUnit build and test system. When I'm done I'll be able to run all of the JSFUnit tests against 6-8 combinations of containers and JSF versions.
As soon as that is done, I can start looking at it. Or, if you'd like to work on it I'd be happy to accept your code. To finish the implementation you just have to find the javascript that RichFaces is using for redirect/expired message/reload and implement that using java and httpunit.
Stan -
2. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 2, 2008 7:25 PM (in response to kragoth)This is my current work around....seems to work well enough.
/** * Use this method to click on one of the menu options in the navigation * drop down menus. * * @param client * @param id of the menu item you wish to click on */ public static void clickNavigationDropDownMenuOption(JSFClientSession client, String id) throws SAXException, IOException { WebForm form = client.getForm(id); WebRequestFactory requestFactory = new WebRequestFactory(client); PostMethodWebRequest req = requestFactory.buildRequest(id); req.setParameter(form.getID() + NamingContainer.SEPARATOR_CHAR + id + NamingContainer.SEPARATOR_CHAR + "hidden", form.getID() + NamingContainer.SEPARATOR_CHAR + id); client.doWebRequest(req); }
I assume this must be similar to what the javascript does havn't really had a look :P -
3. Re: How long till JSFUnit (richfaces) supports redirect?
ssilvert Apr 8, 2008 4:03 PM (in response to kragoth)I implemented this in the client.
http://jira.jboss.com/jira/browse/JSFUNIT-88
So if you have something like this in your xhtml:<a4j:commandButton id="redirect" action="redirectAction"/>
And this for your navigation:<navigation-case> <from-outcome>redirectAction</from-outcome> <to-view-id>/pages/redirectToHere.xhtml</to-view-id> <redirect/> </navigation-case>
This code will work:JSFClientSession client = new JSFClientSession("/index.jsf"); Ajax4jsfClient ajaxClient = new Ajax4jsfClient(client); JSFServerSession server = new JSFServerSession(client); ajaxClient.ajaxSubmit("redirect"); assertEquals("/pages/redirectToHere.xhtml", server.getCurrentViewID());
Please give it try when you have a chance.
Stan -
4. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 8, 2008 10:32 PM (in response to kragoth)Unfortunately by upgrading all my jsfunit tests fail now with the following exception:
Testcase: testSearchAndMaintainTenure(gekko.web.jsfunit.pages.tenure.TenureMaintenanceTest): Caused an ERROR [gekko.junit] String index out of range: -1 [gekko.junit] java.lang.StringIndexOutOfBoundsException: String index out of range: -1 [gekko.junit] at java.lang.String.substring(String.java:1932) [gekko.junit] at java.lang.String.substring(String.java:1905) [gekko.junit] at org.jboss.jsfunit.facade.JSFClientSession.setMojarraCmdLinkParams(JSFClientSession.java:506) [gekko.junit] at org.jboss.jsfunit.facade.JSFClientSession.setCmdLinkParams(JSFClientSession.java:498) [gekko.junit] at org.jboss.jsfunit.facade.JSFClientSession.clickCommandLink(JSFClientSession.java:451) [gekko.junit] at gekko.web.jsfunit.pages.root.HomePageDriver.clickSubmit(HomePageDriver.java:26) [gekko.junit] at gekko.web.jsfunit.pages.GekkoWebTest.afterSetUp(GekkoWebTest.java:48) [gekko.junit] at gekko.web.jsfunit.pages.GekkoWebTest.setUp(GekkoWebTest.java:30) [gekko.junit] at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153) [gekko.junit] at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119) [gekko.junit] at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93) [gekko.junit] at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:217) [gekko.junit] at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java) [gekko.junit] at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101) [gekko.junit] at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:217) [gekko.junit] at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java) [gekko.junit] at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72) [gekko.junit] at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:217) [gekko.junit] at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java) [gekko.junit] at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) [gekko.junit] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [gekko.junit] at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) [gekko.junit] at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:302) [gekko.junit] at org.ajax4jsf.Filter.doFilter(Filter.java:175) [gekko.junit] at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68) [gekko.junit] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [gekko.junit] at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [gekko.junit] at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147) [gekko.junit] at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276) [gekko.junit] at org.ajax4jsf.Filter.doFilter(Filter.java:175) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [gekko.junit] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [gekko.junit] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [gekko.junit] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) [gekko.junit] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) [gekko.junit] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [gekko.junit] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [gekko.junit] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) [gekko.junit] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) [gekko.junit] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) [gekko.junit] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) [gekko.junit] at java.lang.Thread.run(Thread.java:619)
I'm still trying to figure out what is going on. If I can get it working I will look at trying what you have suggested.
Thanks for your continued support! -
5. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 8, 2008 11:25 PM (in response to kragoth)It appears that this method in the JSFClientSession is at fault
// for Mojarra (JSF RI 1.2) private void setMojarraCmdLinkParams(WebRequest req, String clientID) throws SAXException, IOException { String script = this.webResponse.getElementWithID(clientID).getAttribute("onclick"); script = script.substring(script.indexOf("{jsfcljs(")); String[] jsfcljsParams = script.split(",'"); String paramString = jsfcljsParams[1]; // remove trailing single-quote (most cases) if (paramString.endsWith("'")) { paramString = paramString.substring(0, paramString.length() - 1); } else // last param empty so it looked like 'foo,bar,foo,bar,','' { paramString += ", "; // add a space to make next split work } String[] requestParams = paramString.split(","); for (int i=0; i < requestParams.length; i += 2) { String paramName = requestParams; String paramValue = requestParams[i + 1]; req.setParameter(paramName, paramValue); } }
The line that causes the issue is this:script = script.substring(script.indexOf("{jsfcljs("));
script is = "" so this will always through an exception.
I'm not sure how your tests even ran. (You are running tests that just click a non ajax command button right?) -
6. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 8, 2008 11:47 PM (in response to kragoth)through = throw :P
-
7. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 9, 2008 12:04 AM (in response to kragoth)I'm not sure how your tests even ran. (You are running tests that just click a non ajax command button right?)
I realised I should probably clarify what I meant by this (cause it could come across the wrong way). I realise that you do have tests running and I've had a look at your continous build that says all the tests ran fine.
So I'm wondering where in your tests you click a non ajax command button so that I can have a look at what is different between your test and mine! -
8. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 9, 2008 12:30 AM (in response to kragoth)Ok, I'm gonna say this is all my fault!!!
I was using clickCommandLink on buttons when I should have been using submit!
So, forget everything I've just said. :P lol -
9. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 9, 2008 12:41 AM (in response to kragoth)Ok, I've implemented your solution using the ajaxSubmit, so now my code looks like this.
RichFacesClient rclient; ... public void clickDetailsMenuTenureOption() throws IOException, SAXException { rclient.ajaxSubmit("tenureMenuOptions"); }
And it works!!!!! :D
Thanks heaps, much cleaner then my previous solution! -
10. Re: How long till JSFUnit (richfaces) supports redirect?
ssilvert Apr 9, 2008 8:41 AM (in response to kragoth)"Kragoth" wrote:
I was using clickCommandLink on buttons when I should have been using submit!
So, forget everything I've just said. :P lol
I should be throwing a more helpful exception in that case.
Stan -
11. Re: How long till JSFUnit (richfaces) supports redirect?
ssilvert Apr 9, 2008 3:02 PM (in response to kragoth)"stan.silvert@jboss.com" wrote:
"Kragoth" wrote:
I was using clickCommandLink on buttons when I should have been using submit!
So, forget everything I've just said. :P lol
I should be throwing a more helpful exception in that case.
Stan
And now I do: http://jira.jboss.com/jira/browse/JSFUNIT-89 -
12. Re: How long till JSFUnit (richfaces) supports redirect?
kragoth Apr 13, 2008 8:00 PM (in response to kragoth)Nice. I'll upgrade soon. :)