throw new IOException("User not logged when trying to add an event");
ctx.recordTime();
loadStatics(addEventStatics);
MultipartPostMethod post = new MultipartPostMethod(addEventResultURL);
GetMethod eventForm = new GetMethod(addEventURL);
// TODO: Implement prepareEvent() for Rails form data
StringBuilder buffer = new StringBuilder(256);
post.addParameter("commit", "Create");
// post.addParameter("controller", "events");
post.addParameter("event[title]", RandomUtil.randomText(random, 15, 20));
post.addParameter("event[summary]", RandomUtil.randomText(random, 50, 200));
post.addParameter("event[description]", RandomUtil.randomText(random, 100, 495));
post.addParameter("event[telephone]", RandomUtil.randomPhone(random, buffer));
post.addParameter("event[event_timestamp(1i)]", "2008");
post.addParameter("event[event_timestamp(2i)]", "10");
post.addParameter("event[event_timestamp(3i)]", "20");
post.addParameter("event[event_timestamp(4i)]", "20");
post.addParameter("event[event_timestamp(5i)]", "10");
Part imagePart = new FilePart("event_image", eventImg, "image/jpeg", null);
Part docPart = new FilePart("event_document", eventPdf, "application/pdf", null);
post.addPart(imagePart);
post.addPart(docPart);
post.addParameter("tag_list", "tag1");
addAddress(post);
// GET the new event form within a user session
httpClient.executeMethod(eventForm);
String responseBuffer = eventForm.getResponseBodyAsString();
if (responseBuffer.length() == 0)
throw new IOException("Received empty response");
// Parse the authenticity_token from the response
String token = parseAuthToken(responseBuffer);
if (token != null)
post.addParameter("authenticity_token", token);
doMultiPartPost(post, "Event was successfully created.");
ctx.recordTime();
++driverMetrics.addEventTotal;