public void testCreateUsers() throws IOException, SAXException {
WebConversation webConversation = new WebConversation();
webConversation.setExceptionsThrownOnErrorStatus(false);
Performance performance = Performance.getDefault();
PerformanceMeter meter = performance.createPerformanceMeter("SimpleServerUserStressTest#testCreateUsers");
final int USER_COUNT = 10001;
meter.start();
long start = System.currentTimeMillis();
for (int i = 0; i < USER_COUNT; i++) {
long current_start = System.currentTimeMillis();
// create a user
Map<String, String> params = new HashMap<String, String>();
String login = getRandomName();
params.put(UserConstants.KEY_LOGIN, login);
params.put(UserConstants2.FULL_NAME, getRandomName() + " " + getRandomName());
params.put(UserConstants2.EMAIL, login + "@example.com");
params.put(UserConstants2.PASSWORD, getRandomName() + System.currentTimeMillis());
WebRequest request = getPostUsersRequest("", params, true);
WebResponse response = webConversation.getResponse(request);
assertEquals(response.getText(), HttpURLConnection.HTTP_OK, response.getResponseCode());
if (i % 1000 == 0) {
long end = System.currentTimeMillis();
long avg = (end - start) / (i + 1);
long current = end - current_start;
System.out.println("Created user " + i + " in " + current + "ms, average time per user: " + avg + "ms");
}
}
meter.stop();
meter.commit();
}