}
private void uploadWithEvents(RepositoryItem repositoryItem,
File fileToUpload) throws URISyntaxException,
FileNotFoundException, IOException, InterruptedException {
RepositoryHttpRecorder recorder = repositoryItem
.createRepositoryHttpRecorder();
final CountDownLatch started = new CountDownLatch(1);
recorder.addSessionStartedListener(new RepositoryHttpEventListener<HttpSessionStartedEvent>() {
@Override
public void onEvent(HttpSessionStartedEvent event) {
started.countDown();
}
});
final CountDownLatch terminated = new CountDownLatch(1);
recorder.addSessionTerminatedListener(new RepositoryHttpEventListener<HttpSessionTerminatedEvent>() {
@Override
public void onEvent(HttpSessionTerminatedEvent event) {
terminated.countDown();
}
});
uploadFileWithPOST(recorder.getURL(), fileToUpload);
// TODO We need to be sure that this events appear in the order
// specified. This test doesn't control this
assertTrue("Started event didn't sent in 10 seconds",