*
*/
public abstract class RESTAbstractTest extends TestCase {
public static FormRepresentation createMockForm(String title, String... params) {
FormRepresentation form = new FormRepresentation();
HeaderRepresentation header = new HeaderRepresentation();
header.setValue(title);
form.addFormItem(header);
TableRepresentation table = new TableRepresentation();
table.setRows(params.length);
table.setColumns(2);
table.setHeight("" + (params.length * 30) + "px");
for (int index = 0; index < params.length; index++) {
String paramName = params[index];
LabelRepresentation labelName = new LabelRepresentation();
labelName.setValue(paramName);
labelName.setWidth("100px");
table.setElement(index, 0, labelName);
TextFieldRepresentation textField = new TextFieldRepresentation();
textField.setWidth("200px");
OutputData data = new OutputData();
data.setName(paramName);
data.setMimeType("multipart/form-data");
data.setFormatter(null);
textField.setOutput(data);
table.setElement(index, 1, textField);
}
LabelRepresentation labelParams = new LabelRepresentation();
labelParams.setValue("Parameters:");
form.addFormItem(labelParams);
form.addFormItem(table);
CompleteButtonRepresentation completeButton = new CompleteButtonRepresentation();
completeButton.setText("Complete");
form.addFormItem(completeButton);
form.setAction("complete");
form.setEnctype("multipart/form-data");
form.setMethod("POST");
form.setName(title + "AutoForm");
return form;
}