}
public void runTestingLoop() {
try {
Random r = new Random();
JSONObject theBatchRequest = new JSONObject();
JSONArray theRequests = new JSONArray();
JSONObject theRequest = new JSONObject();
theRequest.put("targetPort", 12345);
theRequest.put("targetHost", "127.0.0.1");
theRequest.put("timeoutClock", 3000);
theRequest.put("forPlayerName", "");
theRequests.put(theRequest);
theRequests.put(theRequest);
theBatchRequest.put("requests", theRequests);
theBatchRequest.put("callbackURL", "http://127.0.0.1:12346");
int nRequests = 0;
while (true) {
theRequest.put("requestContent", "" + r.nextLong());
theRequest.put("timestamp", System.currentTimeMillis());
assertEquals("okay", RemoteResourceLoader.postRawWithTimeout("http://127.0.0.1:" + TiltyardRequestFarm.SERVER_PORT, theBatchRequest.toString(), 5000));
nRequests++;
Thread.sleep(10);
int curNumSuccesses = nSuccesses.get();
System.out.println("Successes so far: " + curNumSuccesses + " vs Requests: " + nRequests);