use of com.sun.ts.tests.jsf.api.jakarta_faces.component.common.TCKConverter in project faces by jakartaee.
the class TestServlet method uiInputValidate4Test.
@Override
public void uiInputValidate4Test(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
UIInput input = (UIInput) createComponent();
input.setRendererType(null);
UISelectItem item1 = new UISelectItem();
item1.setItemValue("converted");
UISelectItem item2 = new UISelectItem();
item2.setItemValue("converted2");
input.getChildren().add(item1);
input.getChildren().add(item2);
FacesContext context = getFacesContext();
UIViewRoot root = getApplication().getViewHandler().createView(context, "/root.xhtml");
context.setViewRoot(root);
root.getChildren().add(input);
Converter converter = new TCKConverter();
input.setConverter(converter);
input.setSubmittedValue("new");
input.setValid(true);
input.setRequired(true);
input.validate(context);
if (!"converted".equals(input.getValue())) {
out.println(JSFTestUtil.FAIL + " Converter available to the component" + " via getConverter(), but the converter wasn't called.");
out.println("Expected the value after conversion to be 'converted'");
out.println("Value received: " + input.getValue());
return;
}
// now verify the proper behavior if conversion fails
input.setSubmittedValue("fail");
input.validate(context);
if (input.isValid()) {
out.println(JSFTestUtil.FAIL + " Conversion failure should have resulted" + " in the component in question being marked as invalid.");
return;
}
if (JSFTestUtil.getAsArray(context.getMessages()).length < 1) {
out.println(JSFTestUtil.FAIL + " No messages queued as required in the " + "case of conversion failure.");
return;
}
out.println(JSFTestUtil.PASS);
}
use of com.sun.ts.tests.jsf.api.jakarta_faces.component.common.TCKConverter in project faces by jakartaee.
the class TestServlet method uiInputValidate4Test.
public void uiInputValidate4Test(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
UIInput input = (UIInput) createComponent();
input.setRendererType(null);
FacesContext context = getFacesContext();
UIViewRoot root = getApplication().getViewHandler().createView(context, "/root.xhtml");
context.setViewRoot(root);
root.getChildren().add(input);
Converter converter = new TCKConverter();
input.setConverter(converter);
input.setSubmittedValue("value");
input.setValid(true);
input.setRequired(true);
input.validate(context);
if (!"converted".equals(input.getValue())) {
out.println(JSFTestUtil.FAIL + " Converter available to the component" + " via getConverter(), but the converter wasn't called.");
out.println("Expected the value after conversion to be 'converted'");
out.println("Value received: " + input.getValue());
return;
}
// now verify the proper behavior if conversion fails
input.setSubmittedValue("fail");
input.validate(context);
if (input.isValid()) {
out.println(JSFTestUtil.FAIL + " Conversion failure should have resulted" + " in the component in question being marked as invalid.");
return;
}
if (JSFTestUtil.getAsArray(context.getMessages()).length != 1) {
out.println(JSFTestUtil.FAIL + " No messages queued as required in the " + "case of conversion failure.");
return;
}
out.println(JSFTestUtil.PASS);
}
Aggregations