use of org.opencastproject.workingfilerepository.api.WorkingFileRepository in project opencast by opencast.
the class WorkspaceImplTest method testGetNoFilename.
@Test
public void testGetNoFilename() throws Exception {
final File expectedFile = testFolder.newFile("test.txt");
FileUtils.write(expectedFile, "asdf");
expectedFile.deleteOnExit();
WorkingFileRepository repo = EasyMock.createNiceMock(WorkingFileRepository.class);
EasyMock.expect(repo.getBaseUri()).andReturn(new URI("http://localhost:8080/files")).anyTimes();
EasyMock.replay(repo);
workspace.setRepository(repo);
RequestRunner<Either<String, Option<File>>> requestRunner = new TrustedHttpClient.RequestRunner<Either<String, Option<File>>>() {
@Override
public Either<Exception, Either<String, Option<File>>> run(Function<HttpResponse, Either<String, Option<File>>> f) {
Either<String, Option<File>> right = Either.right(Option.some(expectedFile));
return Either.right(right);
}
};
TrustedHttpClient trustedHttpClient = EasyMock.createNiceMock(TrustedHttpClient.class);
EasyMock.expect(trustedHttpClient.<Either<String, Option<File>>>runner(EasyMock.anyObject(HttpUriRequest.class))).andReturn(requestRunner).anyTimes();
EasyMock.replay(trustedHttpClient);
workspace.setTrustedHttpClient(trustedHttpClient);
File resultingFile = workspace.get(URI.create("http://foo.com/myaccount/videos/"));
Assert.assertEquals(expectedFile, resultingFile);
}
Aggregations