Example #1
0
 /** Verify that the conversion error works for SelectMany */
 public void testSelectManyMismatchValue() throws Exception {
   HtmlPage page = getPage("/faces/jsp/selectManyMismatchValue.jsp");
   List list = getAllElementsOfGivenClass(page, null, HtmlSubmitInput.class);
   HtmlSubmitInput button = (HtmlSubmitInput) list.get(0);
   list = getAllElementsOfGivenClass(page, null, HtmlSelect.class);
   HtmlSelect options = (HtmlSelect) list.get(0);
   String chosen[] = {"one", "three"};
   options.fakeSelectedAttribute(chosen);
   page = (HtmlPage) button.click();
   assertTrue(-1 != page.asText().indexOf("one three"));
   assertTrue(-1 != page.asText().indexOf("#{test3.selection}"));
 }
Example #2
0
  public void testSelectManyTypeInts() throws Exception {
    HtmlPage page = getPage("/faces/jsp/selectManyTypeInts.jsp");
    List list = getAllElementsOfGivenClass(page, null, HtmlSubmitInput.class);
    HtmlSubmitInput button = (HtmlSubmitInput) list.get(0);
    list = getAllElementsOfGivenClass(page, null, HtmlSelect.class);
    HtmlSelect options = (HtmlSelect) list.get(0);

    String chosen[] = {"2", "3"};
    options.fakeSelectedAttribute(chosen);
    page = (HtmlPage) button.click();
    ResourceBundle messages = ResourceBundle.getBundle("javax.faces.Messages");
    String message = messages.getString("javax.faces.component.UISelectMany.INVALID");
    // it does not have a validation message
    assertTrue(-1 == page.asText().indexOf("Validation Error"));
  }
Example #3
0
  /**
   * On SelectMany, test that the membership test works and doesn't produce spurious
   * ValueChangeEvent instances.
   */
  public void testSelectManyInvalidValue() throws Exception {
    HtmlPage page = getPage("/faces/jsp/selectManyInvalidValue.jsp");
    List list = getAllElementsOfGivenClass(page, null, HtmlSubmitInput.class);
    HtmlSubmitInput button = (HtmlSubmitInput) list.get(0);
    list = getAllElementsOfGivenClass(page, null, HtmlSelect.class);
    HtmlSelect options = (HtmlSelect) list.get(0);
    Random random = new Random(4143);
    String str = new String((new Float(random.nextFloat())).toString());

    String chosen[] = {
      (new Float(random.nextFloat())).toString(), (new Float(random.nextFloat())).toString()
    };
    options.fakeSelectedAttribute(chosen);
    page = (HtmlPage) button.click();
    ResourceBundle messages = ResourceBundle.getBundle("javax.faces.Messages");
    String message = messages.getString("javax.faces.component.UISelectMany.INVALID");
    // it does have a validation message
    assertTrue(-1 != page.asText().indexOf("Validation Error"));
    // it does not have a value change message
    assertTrue(-1 == page.asText().indexOf("value changed"));
  }