use of org.apache.tapestry5.corelib.components.Form in project tapestry-5 by apache.
the class MultipartServletRequestFilterTest method multipartRequestIsDecoded.
@Test
public void multipartRequestIsDecoded() throws Exception {
MultipartDecoder decoder = newMock(MultipartDecoder.class);
HttpServletRequest request = mockHttpServletRequest();
HttpServletRequest decodedRequest = mockHttpServletRequest();
HttpServletResponse response = mockHttpServletResponse();
HttpServletRequestHandler handler = newMock(HttpServletRequestHandler.class);
MultipartServletRequestFilter filter = new MultipartServletRequestFilter(decoder);
expect(request.getMethod()).andReturn("post");
expect(request.getContentType()).andReturn("multipart/form");
expect(decoder.decode(request)).andReturn(decodedRequest);
expect(handler.service(decodedRequest, response)).andReturn(true);
replay();
boolean isHandled = filter.service(request, response, handler);
assertTrue(isHandled);
verify();
}
use of org.apache.tapestry5.corelib.components.Form in project tapestry-5 by apache.
the class UploadTest method begin_render_writes_input_tag.
@Test
public void begin_render_writes_input_tag() throws Exception {
MarkupWriter writer = createMarkupWriter();
writer.element("form");
FormSupport formSupport = mockFormSupport();
ComponentResources resources = mockComponentResources();
FieldValidator validator = mockFieldValidator();
Request request = mockRequest();
train_isXHR(request, false);
formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
validator.render(writer);
resources.renderInformalParameters(writer);
replay();
Upload component = new Upload(null, null, null, null, resources, null);
component.injectDecorator(new BaseValidationDecorator()).injectFormSupport(formSupport).injectFieldValidator(validator).injectRequest(request);
component.beginRender(writer);
Element element = writer.getElement();
assertNotNull(element);
assertEquals(element.getName(), "input");
assertEquals(element.getAttribute("type"), "file");
// assertEquals(element.getAttribute("name"),null);
// assertEquals(element.getAttribute("id"),null);
verify();
}
use of org.apache.tapestry5.corelib.components.Form in project tapestry-5 by apache.
the class UploadTest method validation_decorator_invoked_inside_begin_render.
@Test
public void validation_decorator_invoked_inside_begin_render() throws Exception {
getMocksControl().checkOrder(true);
ComponentResources resources = mockComponentResources();
Upload component = new Upload(null, null, null, null, resources, null);
MarkupWriter writer = createMarkupWriter();
writer.element("form");
FieldValidator validator = mockFieldValidator();
Request request = mockRequest();
FormSupport formSupport = mockFormSupport();
formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
component.injectFormSupport(formSupport).injectRequest(request);
ValidationDecorator decorator = mockValidationDecorator();
component.injectDecorator(decorator).injectFieldValidator(validator);
validator.render(writer);
resources.renderInformalParameters(writer);
decorator.insideField(component);
train_isXHR(request, false);
replay();
component.beginRender(writer);
verify();
}
use of org.apache.tapestry5.corelib.components.Form in project tapestry-5 by apache.
the class BeanModelImpl method reorder.
public BeanModel<T> reorder(String... propertyNames) {
List<String> remainingPropertyNames = CollectionFactory.newList(this.propertyNames);
List<String> reorderedPropertyNames = CollectionFactory.newList();
for (String name : propertyNames) {
PropertyModel model = get(name);
// Get the canonical form (which may differ from name in terms of case)
String canonical = model.getPropertyName();
reorderedPropertyNames.add(canonical);
remainingPropertyNames.remove(canonical);
}
this.propertyNames.clear();
this.propertyNames.addAll(reorderedPropertyNames);
// Any unspecified names are ordered to the end. Don't want them? Remove them instead.
this.propertyNames.addAll(remainingPropertyNames);
return this;
}
use of org.apache.tapestry5.corelib.components.Form in project tapestry-5 by apache.
the class FormTest method record_error.
@Test
public void record_error() {
ValidationTracker tracker = mockValidationTracker();
String message = "A recorded message.";
tracker.recordError(message);
replay();
Form form = new Form();
form.setTracker(tracker);
form.recordError(message);
verify();
}
Aggregations