use of de.schlichtherle.io.FileOutputStream in project opencast by opencast.
the class XACMLSecurityTest method setUp.
@Before
public void setUp() throws Exception {
authzService = new XACMLAuthorizationService();
// Mock security service
securityService = EasyMock.createMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andAnswer(() -> new JaxbUser(currentUser, "test", organization, currentRoles)).anyTimes();
// Mock workspace
Workspace workspace = EasyMock.createMock(Workspace.class);
final Capture<InputStream> in = EasyMock.newCapture();
final Capture<URI> uri = EasyMock.newCapture();
EasyMock.expect(workspace.put(EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString(), EasyMock.capture(in))).andAnswer(() -> {
final File file = testFolder.newFile();
FileOutputStream out = new FileOutputStream(file);
IOUtils.copyLarge(in.getValue(), out);
IOUtils.closeQuietly(out);
IOUtils.closeQuietly(in.getValue());
return file.toURI();
}).anyTimes();
EasyMock.expect(workspace.get(EasyMock.capture(uri))).andAnswer(() -> new File(uri.getValue())).anyTimes();
EasyMock.expect(workspace.read(EasyMock.capture(uri))).andAnswer(() -> new FileInputStream(uri.getValue().getPath())).anyTimes();
workspace.delete(EasyMock.anyObject(URI.class));
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(securityService, workspace);
authzService.setWorkspace(workspace);
authzService.setSecurityService(securityService);
}
use of de.schlichtherle.io.FileOutputStream in project opencast by opencast.
the class Mpeg7Test method testNewInstance.
/**
* Test method for {@link org.opencastproject.mediapackage.mpeg7.Mpeg7CatalogImpl#save()}.
*/
@Test
public void testNewInstance() throws Exception {
// Read the sample catalog
Mpeg7Catalog mpeg7Sample = new Mpeg7CatalogImpl(catalogFile.toURI().toURL().openStream());
// Create a new catalog and fill it with a few fields
mpeg7TempFile = testFolder.newFile();
// TODO: Add sample tracks to new catalog
// TODO: Add sample video segments to new catalog
// TODO: Add sample annotations to new catalog
// Store the mpeg7 catalog contents in the temp file
Mpeg7CatalogService mpeg7Service = new Mpeg7CatalogService();
InputStream in = mpeg7Service.serialize(mpeg7Sample);
FileOutputStream out = new FileOutputStream(mpeg7TempFile);
IOUtils.copy(in, out);
// Re-read the saved catalog and test for its content
Mpeg7Catalog mpeg7NewFromDisk = new Mpeg7CatalogImpl(mpeg7TempFile.toURI().toURL().openStream());
// TODO: Test content
testContent(mpeg7NewFromDisk);
}
Aggregations