use of com.sun.ts.tests.jsf.api.jakarta_faces.component.common.BufferedResponseWrapper in project faces by jakartaee.
the class TestServlet method uiComponentGetSetValueExpressionTest.
// ------------------------------------------- Test Methods ----
@Override
public void uiComponentGetSetValueExpressionTest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BufferedResponseWrapper wrapper = new BufferedResponseWrapper(response);
super.uiComponentGetSetValueExpressionTest(request, wrapper);
String result = wrapper.getBufferedWriter().toString();
PrintWriter out = response.getWriter();
if (result.indexOf(JSFTestUtil.PASS) == -1) {
out.println(result);
return;
}
// default processing of get,setValueExpression is ok, now validate
// processing specific to UIGraphic
request.setAttribute("tckUrl", "http://java.sun.com");
ExpressionFactory factory = JSFTestUtil.getExpressionFactory(servletContext);
ValueExpression expression = factory.createValueExpression(getFacesContext().getELContext(), "#{requestScope.tckUrl}", java.lang.String.class);
ValueExpression literalExpr = factory.createValueExpression(getFacesContext().getELContext(), "http://java.net", java.lang.String.class);
UIGraphic graphic = (UIGraphic) createComponent();
graphic.setValueExpression("url", expression);
if (!"http://java.sun.com".equals(graphic.getValue())) {
out.println(JSFTestUtil.FAIL + " setValueExpression() with a key of 'url'" + " didn't set the ValueExpression provided as the value" + " of the component.");
out.println("Expected: http://java.net");
out.println("Received: " + graphic.getValue());
return;
}
// ensure there is no special processing if the ValueExpression
// happens to be literal
graphic.setValueExpression("url", literalExpr);
if (!"http://java.net".equals(graphic.getValue())) {
out.println(JSFTestUtil.FAIL + " setValueExpression() with a key of 'url'" + " didn't set the literal ValueExpression provided as the " + "value of the component.");
out.println("Expected: " + expression);
out.println("Received: " + graphic.getValue());
return;
}
out.println(JSFTestUtil.PASS);
}
use of com.sun.ts.tests.jsf.api.jakarta_faces.component.common.BufferedResponseWrapper in project faces by jakartaee.
the class TestServlet method uiComponentGetSetValueExpressionTest.
// ------------------------------------------- Test Methods ----
@Override
public void uiComponentGetSetValueExpressionTest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BufferedResponseWrapper wrapper = new BufferedResponseWrapper(response);
super.uiComponentGetSetValueExpressionTest(request, wrapper);
String result = wrapper.getBufferedWriter().toString();
PrintWriter out = response.getWriter();
if (result.indexOf(JSFTestUtil.PASS) == -1) {
out.println(result);
return;
}
// default processing of get,setValueExpression is ok, now validate
// processing specific to UIGraphic
request.setAttribute("value", "selectedValue");
ExpressionFactory factory = JSFTestUtil.getExpressionFactory(servletContext);
ValueExpression expression = factory.createValueExpression(getFacesContext().getELContext(), "#{requestScope.value}", java.lang.String.class);
UISelectBoolean selBoolean = (UISelectBoolean) createComponent();
selBoolean.setValueExpression("selected", expression);
if (!"selectedValue".equals(selBoolean.getValue())) {
out.println(JSFTestUtil.FAIL + " setValueExpression() with a key of 'selected'" + " didn't set the ValueExpression provided as the value" + " of the component.");
out.println("Expected: " + expression);
out.println("Received: " + selBoolean.getValue());
return;
}
out.println(JSFTestUtil.PASS);
}
use of com.sun.ts.tests.jsf.api.jakarta_faces.component.common.BufferedResponseWrapper in project faces by jakartaee.
the class TestServlet method uiComponentGetSetValueExpressionTest.
// ------------------------------------------- Test Methods ----
@Override
public void uiComponentGetSetValueExpressionTest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BufferedResponseWrapper wrapper = new BufferedResponseWrapper(response);
super.uiComponentGetSetValueExpressionTest(request, wrapper);
String result = wrapper.getBufferedWriter().toString();
PrintWriter out = response.getWriter();
if (result.indexOf(JSFTestUtil.PASS) == -1) {
out.println(result);
return;
}
List<String> values = new ArrayList<String>();
values.add("value1");
values.add("value2");
// default processing of get,setValueExpression is ok, now validate
// processing specific to UIGraphic
request.setAttribute("values", values);
ExpressionFactory factory = JSFTestUtil.getExpressionFactory(servletContext);
ValueExpression expression = factory.createValueExpression(getFacesContext().getELContext(), "#{requestScope.values}", java.util.List.class);
UISelectMany many = (UISelectMany) createComponent();
many.setValueExpression("selectedValues", expression);
if (many.getValue() != values) {
out.println(JSFTestUtil.FAIL + " getValue() returned unexpected value" + " after having called setValueExpression().");
out.println("Expected: " + values);
out.println("Received: " + many.getValue());
}
out.println(JSFTestUtil.PASS);
}
Aggregations