Package org.jboss.jsfunit.jsfsession

Examples of org.jboss.jsfunit.jsfsession.JSFClientSession


   }

   public void testAjaxForm() throws IOException
   {
      JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/form.jsf");
      JSFClientSession client = jsfSession.getJSFClientSession();
      JSFServerSession server = jsfSession.getJSFServerSession();
     
      assertEquals("Name:", server.getComponentValue("ajaxSubmitTrueForm:name"));
      assertEquals("Name:", server.getComponentValue("ajaxSubmitFalseForm:name"));
     
      client.click("SetBoth");
      assertEquals("Mark", server.getManagedBeanValue("#{userBean.name}"));
      assertEquals("Name:Mark", server.getComponentValue("ajaxSubmitTrueForm:name"));
      assertEquals("Name:Mark", server.getComponentValue("ajaxSubmitFalseForm:name"));
     
      client.click("SetToJohn");
      assertEquals("Jonh", server.getManagedBeanValue("#{userBean.name}"));
      assertEquals("Name:Jonh", server.getComponentValue("ajaxSubmitTrueForm:name"));
      assertEquals("Name:Jonh", server.getComponentValue("ajaxSubmitFalseForm:name"));
   }
View Full Code Here


   }

   public void testActionParam() throws IOException
   {
      JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/actionparam.jsf");
      JSFClientSession client = jsfSession.getJSFClientSession();
      JSFServerSession server = jsfSession.getJSFServerSession();
     
      client.click("SetToAlex");
      assertEquals("Alex", server.getManagedBeanValue("#{userBean.name}"));
     
      client.click("SetToJohn");
      assertEquals("John", server.getManagedBeanValue("#{userBean.name}"));
   }
View Full Code Here

 
 
  public void testPoll_OnOffTest() throws InterruptedException, IOException
  {
    JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/poll.jsf");
    JSFClientSession client = jsfSession.getJSFClientSession();
    RichFacesClient ajaxClient = new RichFacesClient(client);
    JSFServerSession server = jsfSession.getJSFServerSession();

    // Get the backing bean to check activity
    PollBean pb = (PollBean)server.getManagedBeanValue(_POLLBEAN);
    assertNotNull("Can't find PollBean",pb);
    // Make sure polling is enabled
    assertTrue("Polling is not enabled in the PollBean",pb.getPollEnabled());
   
    // Get poll control to check status
    UIPoll poll = (UIPoll)server.findComponent(_POLL_ID);
    assertNotNull("Can't find server side poll component",poll);
    int interval = poll.getInterval();
    // Make sure polling is enabled
    assertTrue("Polling is not enabled in the component",poll.isEnabled());
   
    // Make sure the date is updating
    Date startDate = pb.getLasttime();
    Thread.sleep(interval*4);
    Date endDate = pb.getLasttime();
    assertFalse("Date is not being updated in the PollBean",startDate.equals(endDate));
   
    // Get control button and disable polling
    HtmlButtonInput button = (HtmlButtonInput)client.getElement(_BUTTON_ID);
    assertNotNull("Can't find polling control button ["+_BUTTON_ID+"]",button);
    button.click();

    // Wait for polling state to change
    Thread.sleep(interval*2);   
   
    // Make sure we're no longer polling
    assertFalse("Polling should be disabled in the PollBean",pb.getPollEnabled());
    // Check the server-side control also (TBD: This causes IllegalStateException)
//    poll = (UIPoll)server.findComponent(_POLL_ID);
//    assertFalse("Polling should be disabled in the component",poll.isEnabled());
    // Make sure the date is NOT updating
    startDate = pb.getLasttime();
    Thread.sleep(interval*4);
    endDate = pb.getLasttime();
    assertTrue("Date should not be updating in the PollBean",startDate.equals(endDate));
   
    // Turn polling back on (page was updated, therefore we MUST re-get the control)
    button = (HtmlButtonInput)client.getElement(_BUTTON_ID)
    button.click();

    // Wait for polling state to change
    Thread.sleep(interval*2);   
   
 
View Full Code Here

  }
 
  public void testPoll_StillRunning() throws InterruptedException, IOException
  {
    JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/inplaceInput.jsf")// Anything but the Polling page
    JSFClientSession client = jsfSession.getJSFClientSession();
    RichFacesClient ajaxClient = new RichFacesClient(client);
    JSFServerSession server = jsfSession.getJSFServerSession();
   
    // Get the backing bean to check activity
    PollBean pb = (PollBean)server.getManagedBeanValue(_POLLBEAN);
View Full Code Here

public class AjaxIncludeTest extends ServletTestCase
{
   public void testWizard() throws IOException
   {
      JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/include.jsf");
      JSFClientSession client = jsfSession.getJSFClientSession();
      JSFServerSession server = jsfSession.getJSFServerSession();
     
      client.setValue("fn", "Stan");
      client.setValue("ln", "Silvert");
      client.setValue("comp", "JBoss");
      client.click("wizardNext");
     
      client.setValue("notes", "Here is my note");
      client.click("wizardNext");
      assertEquals("Here is my note", server.getManagedBeanValue("#{profile.notes}"));
     
      String page = client.getPageAsText();
      assertTrue(page.contains("Stan"));
      assertTrue(page.contains("Silvert"));
      assertTrue(page.contains("JBoss"));
      assertTrue(page.contains("Here is my note"));
     
      client.click("wizardPrevious"); // back to Notes input page
      client.click("wizardPrevious"); // back to first input page
      page = client.getPageAsText();
      assertTrue(page.contains("value=\"Stan\""));
      assertEquals("Stan", server.getManagedBeanValue("#{profile.firstName}"));
   }
View Full Code Here

public class AjaxOutputPanelTest extends ServletTestCase
{
   public void testLayoutNone() throws IOException
   {
      JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/outputPanel.jsf");
      JSFClientSession client = jsfSession.getJSFClientSession();
      JSFServerSession server = jsfSession.getJSFServerSession();

      client.type("text1", 'f');
      client.type("text1", 'o');
      client.type("text1", 'o');
     
      assertNull(client.getElement("out1"));
     
      client.type("text2", 'f');
      client.type("text2", 'o');
      client.type("text2", 'o');
     
      HtmlElement span = (HtmlElement)client.getElement("out2");
      assertTrue(span.getTextContent().contains("Approved Text: foo"));
   }
View Full Code Here

public class RichInputNumberSliderTest extends ServletTestCase
{
   public void testNumberSliders() throws IOException
   {
      JSFSession jsfSession = JSFSessionFactory.makeSession("/richfaces/inputNumberSlider.jsf");
      JSFClientSession client = jsfSession.getJSFClientSession();
      RichFacesClient ajaxClient = new RichFacesClient(client);
      JSFServerSession server = jsfSession.getJSFServerSession();
     
      ajaxClient.setInputNumberSlider("slider1", "45");
      ajaxClient.setInputNumberSlider("slider2", "55");
      ajaxClient.setInputNumberSlider("slider3", "945");
      client.click("submit");
     
      String value = (String)server.getComponentValue("slider1");
      assertEquals("45", value);
      value = (String)server.getComponentValue("slider2");
      assertEquals("55", value);
View Full Code Here

      assertEquals(null, server.getManagedBeanValue("#{conference.startDate}"));
      assertEquals(null, server.getManagedBeanValue("#{conference.endDate}"));
      assertEquals(null, server.getManagedBeanValue("#{conference.location}"));
      assertEquals(null, server.getManagedBeanValue("#{conference.topic}"));
     
      JSFClientSession client = jsfSession.getJSFClientSession();
      if (printRenderedOutput)
      {
         System.out.println("GET /submit.jsf HTTP/1.1\n\n" + client.getPageAsText());
      }

      client.setValue("conference:title", "Devoxx");
      client.setValue("conference:startDate", "2010-11-15");
      client.setValue("conference:endDate", "2010-11-19");
      client.setValue("conference:location", "Metropolis, Antwerp, Belgium");
      client.setValue("conference:topic", "Java");
      client.click("conference:submit");
     
      assertEquals("/submission.xhtml", server.getCurrentViewID());

      @SuppressWarnings("unchecked")
      List<Conference> conferences = (List<Conference>) server.getManagedBeanValue("#{conferences}");
      assertNotNull(conferences);
      assertEquals(1, conferences.size());
      Conference conference = conferences.get(0);
      assertEquals("Devoxx", conference.getTitle());
      assertEquals(buildDate(2010, 11, 15).toString(), conference.getStartDate().toString());
      assertEquals(buildDate(2010, 11, 19).toString(), conference.getEndDate().toString());
      assertEquals("Metropolis, Antwerp, Belgium", conference.getLocation());
      assertEquals("Java", conference.getTopic());
   
      if (printRenderedOutput)
      {
         System.out.println("POST /submission.jsf HTTP/1.1\n\n" + client.getPageAsText());
      }

      // not sure why these are null
      //assertEquals("Devoxx", server.getManagedBeanValue("#{conference.title}"));
      //assertEquals("Devoxx", server.getComponentValue("title"));
View Full Code Here

TOP

Related Classes of org.jboss.jsfunit.jsfsession.JSFClientSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.