This content has been marked as final.
Show 2 replies
-
1. Re: simulating click on table row
ssilvert Jul 18, 2008 8:00 PM (in response to wgworek)You might want to try out the new JSFUnit from subversion. It replaces the client with one that is based on HtmlUnit instead of HttpUnit. Though this code is still a few weeks from beta, at least you won't see the NPE you are running into now.
If you look at the online demo, you will see that RichDataFilterSlider has an example JSFUnit test and that example uses rich:dataTable. Click on the source link to see the old version of the test.
http://jsfunit.demo.jboss.com/jboss-jsfunit-examples-richfaces/richfaces/dataFilterSlider.jsf
The new version of the test is below:/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.jsfunit.test.richfaces; import java.io.IOException; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.cactus.ServletTestCase; import org.jboss.jsfunit.jsfsession.JSFClientSession; import org.jboss.jsfunit.jsfsession.JSFSession; import org.jboss.jsfunit.richfaces.RichFacesClient; import org.w3c.dom.Element; /** * Peform JSFUnit tests on RichFaces demo application. * * @author Stan Silvert */ public class RichDataFilterSliderTest extends ServletTestCase { public void testDataFilterSlider() throws IOException { JSFSession jsfSession = new JSFSession("/richfaces/dataFilterSlider.jsf"); JSFClientSession client = jsfSession.getJSFClientSession(); RichFacesClient richClient = new RichFacesClient(client); richClient.setDataFilterSlider("slider_1", "60000"); // The data table is built with random data, so there's nothing to // reliably assert about it except the make of the car. Element element = client.getElement("form1:carList:0:make"); assertEquals("Ford", element.getTextContent()); // Click the link to change make to Chevy. I happen to know it is the // first in the list. client.click("form1:carIndex:0:switchMake"); element = client.getElement("form1:carList:0:make"); assertEquals("Chevrolet", element.getTextContent()); } public static Test suite() { return new TestSuite( RichDataFilterSliderTest.class ); } }
Hope that helps. I won't be around as much for the next few days, but I'll be back on this forum regularly again on Wednesday.
Stan -
2. Re: simulating click on table row
wgworek Jul 21, 2008 12:52 PM (in response to wgworek)With JSFUnit from the trunk it works and no errors are generated. Thanks a lot.
Just in case anybody had a problem. One should use this classes:import org.jboss.jsfunit.jsfsession.JSFClientSession; import org.jboss.jsfunit.jsfsession.JSFServerSession;
and not from org.jboss.jsfunit.facade.