use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class StaticMetadataServiceDublinCoreImplTest method newWorkspace.
private Workspace newWorkspace() throws Exception {
// mock workspace
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
final File dcFile = new File(getClass().getResource("/dublincore.xml").toURI());
final File dcFileDefect = new File(getClass().getResource("/dublincore-defect.xml").toURI());
Assert.assertNotNull(dcFile);
// set expectations
EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andAnswer(new IAnswer<File>() {
@Override
public File answer() throws Throwable {
return EasyMock.getCurrentArguments()[0].toString().contains("-defect") ? dcFileDefect : dcFile;
}
}).anyTimes();
// put into replay mode
EasyMock.replay(workspace);
return workspace;
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class LiveScheduleServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
mimeType = MimeTypes.parseMimeType(MIME_TYPE);
// Osgi Services
serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
searchService = EasyMock.createNiceMock(SearchService.class);
seriesService = EasyMock.createNiceMock(SeriesService.class);
captureAgentService = EasyMock.createNiceMock(CaptureAgentStateService.class);
EasyMock.expect(captureAgentService.getAgentCapabilities("demo-capture-agent")).andReturn(new Properties());
downloadDistributionService = EasyMock.createNiceMock(DownloadDistributionService.class);
EasyMock.expect(downloadDistributionService.getDistributionType()).andReturn(LiveScheduleServiceImpl.DEFAULT_LIVE_DISTRIBUTION_SERVICE).anyTimes();
workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.put(EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyObject(InputStream.class))).andReturn(new URI("http://someUrl"));
dublinCoreService = EasyMock.createNiceMock(DublinCoreCatalogService.class);
assetManager = EasyMock.createNiceMock(AssetManager.class);
authService = new AuthorizationServiceMock();
organizationService = EasyMock.createNiceMock(OrganizationDirectoryService.class);
Organization defOrg = new DefaultOrganization();
Map<String, String> orgProps = new HashMap<String, String>();
orgProps.put(LiveScheduleServiceImpl.PLAYER_PROPERTY, PATH_TO_PLAYER);
orgProps.put(LiveScheduleServiceImpl.ENGAGE_URL_PROPERTY, ENGAGE_URL);
org = new JaxbOrganization(ORG_ID, "Test Organization", defOrg.getServers(), defOrg.getAdminRole(), defOrg.getAnonymousRole(), orgProps);
EasyMock.expect(organizationService.getOrganization(ORG_ID)).andReturn(org).anyTimes();
// Live service configuration
BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(LiveScheduleServiceImpl.LIVE_STREAMING_URL, STREAMING_SERVER_URL);
props.put(LiveScheduleServiceImpl.LIVE_STREAM_MIME_TYPE, "video/x-flv");
props.put(LiveScheduleServiceImpl.LIVE_STREAM_NAME, STREAM_NAME);
props.put(LiveScheduleServiceImpl.LIVE_STREAM_RESOLUTION, "1920x540,960x270");
props.put(LiveScheduleServiceImpl.LIVE_TARGET_FLAVORS, "presenter/delivery");
cc = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(cc.getBundleContext()).andReturn(bc);
EasyMock.expect(cc.getProperties()).andReturn(props);
EasyMock.replay(bc, cc);
service = new LiveScheduleServiceImpl();
service.setJobPollingInterval(1L);
service.setSearchService(searchService);
service.setSeriesService(seriesService);
service.setCaptureAgentService(captureAgentService);
service.setServiceRegistry(serviceRegistry);
service.setWorkspace(workspace);
service.setDublinCoreService(dublinCoreService);
service.setAssetManager(assetManager);
service.setAuthorizationService(authService);
service.setOrganizationService(organizationService);
service.activate(cc);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class SoxServiceTest method setUp.
@Before
public void setUp() throws Exception {
if (!soxInstalled)
return;
// Copy an existing media file to a temp file
File f = new File("src/test/resources/audio-test.flac");
source = File.createTempFile(FilenameUtils.getBaseName(f.getName()), ".flac");
FileUtils.copyFile(f, source);
f = null;
JaxbOrganization org = new DefaultOrganization();
User user = new JaxbUser("admin", "test", org, new JaxbRole(DefaultOrganization.DEFAULT_ORGANIZATION_ADMIN, org));
OrganizationDirectoryService orgDirectory = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgDirectory.getOrganization((String) EasyMock.anyObject())).andReturn(org).anyTimes();
UserDirectoryService userDirectory = EasyMock.createNiceMock(UserDirectoryService.class);
EasyMock.expect(userDirectory.loadUser("admin")).andReturn(user).anyTimes();
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(org).anyTimes();
EasyMock.expect(securityService.getUser()).andReturn(user).anyTimes();
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(source).anyTimes();
BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
EasyMock.expect(bc.getProperty(SoxServiceImpl.CONFIG_SOX_PATH)).andReturn(SOX_BINARY).anyTimes();
ComponentContext cc = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(cc.getBundleContext()).andReturn(bc).anyTimes();
IncidentService incidentService = EasyMock.createNiceMock(IncidentService.class);
// Finish setting up the mocks
EasyMock.replay(bc, cc, orgDirectory, userDirectory, securityService, workspace, incidentService);
// Create and populate the composer service
soxService = new SoxServiceImpl();
serviceRegistry = new ServiceRegistryInMemoryImpl(soxService, securityService, userDirectory, orgDirectory, incidentService);
soxService.setOrganizationDirectoryService(orgDirectory);
soxService.setSecurityService(securityService);
soxService.setServiceRegistry(serviceRegistry);
soxService.setUserDirectoryService(userDirectory);
soxService.setWorkspace(workspace);
soxService.activate(cc);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class AnimateServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
// Skip tests if synfig is not installed
Assume.assumeTrue(runSynfigTests);
// create animate service
animateService = new AnimateServiceImpl();
// create the needed mocks
BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
ComponentContext cc = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(cc.getBundleContext()).andReturn(bc).anyTimes();
Workspace workspace = EasyMock.createMock(Workspace.class);
final String directory = testFolder.newFolder().getAbsolutePath();
EasyMock.expect(workspace.rootDirectory()).andReturn(directory).anyTimes();
final Capture<String> collection = EasyMock.newCapture();
final Capture<String> name = EasyMock.newCapture();
final Capture<InputStream> in = EasyMock.newCapture();
EasyMock.expect(workspace.putInCollection(capture(collection), capture(name), capture(in))).andAnswer(() -> {
File output = new File(directory, "out.mp4");
FileUtils.copyInputStreamToFile(in.getValue(), output);
return output.toURI();
}).once();
// Finish setting up the mocks
EasyMock.replay(bc, cc, workspace);
ServiceRegistry serviceRegistry = EasyMock.createMock(ServiceRegistry.class);
final Capture<String> type = EasyMock.newCapture();
final Capture<String> operation = EasyMock.newCapture();
final Capture<List<String>> args = EasyMock.newCapture();
EasyMock.expect(serviceRegistry.createJob(capture(type), capture(operation), capture(args), EasyMock.anyFloat())).andAnswer(() -> {
// you could do work here to return something different if you needed.
Job job = new JobImpl(0);
job.setJobType(type.getValue());
job.setOperation(operation.getValue());
job.setArguments(args.getValue());
job.setPayload(animateService.process(job));
return job;
}).anyTimes();
EasyMock.replay(serviceRegistry);
animateService.setServiceRegistry(serviceRegistry);
animateService.setWorkspace(workspace);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class AnimateWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
handler = new AnimateWorkflowOperationHandler() {
@Override
protected JobBarrier.Result waitForStatus(Job... jobs) throws IllegalStateException, IllegalArgumentException {
JobBarrier.Result result = EasyMock.createNiceMock(JobBarrier.Result.class);
EasyMock.expect(result.isSuccess()).andReturn(true).anyTimes();
EasyMock.replay(result);
return result;
}
};
file = new File(getClass().getResource("/dc-episode.xml").toURI());
MediaPackage mediaPackage = new MediaPackageBuilderImpl().createNew();
mediaPackage.setIdentifier(new IdImpl("123-456"));
InputStream in = new FileInputStream(file);
Catalog catalog = DublinCores.read(in);
catalog.setFlavor(MediaPackageElements.EPISODE);
// catalog.setURI(getClass().getResource("/dc-episode.xml").toURI());
mediaPackage.add(catalog);
instance = EasyMock.createNiceMock(WorkflowOperationInstanceImpl.class);
EasyMock.expect(instance.getConfiguration("target-flavor")).andReturn("a/b").anyTimes();
EasyMock.expect(instance.getConfiguration("target-tags")).andReturn("a,b,c").anyTimes();
workflow = EasyMock.createMock(WorkflowInstanceImpl.class);
EasyMock.expect(workflow.getMediaPackage()).andReturn(mediaPackage).anyTimes();
EasyMock.expect(workflow.getCurrentOperation()).andReturn(instance).anyTimes();
Job job = new JobImpl(0);
job.setPayload(file.getAbsolutePath());
AnimateService animateService = EasyMock.createMock(AnimateService.class);
EasyMock.expect(animateService.animate(anyObject(), anyObject(), anyObject())).andReturn(job);
Workspace workspace = EasyMock.createMock(Workspace.class);
EasyMock.expect(workspace.put(anyString(), anyString(), anyString(), anyObject())).andReturn(file.toURI()).anyTimes();
EasyMock.expect(workspace.read(anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dc-episode.xml")).anyTimes();
workspace.cleanup(anyObject(Id.class));
EasyMock.expectLastCall();
workspace.delete(anyObject(URI.class));
EasyMock.expectLastCall();
job = new JobImpl(1);
job.setPayload(MediaPackageElementParser.getAsXml(new TrackImpl()));
MediaInspectionService mediaInspectionService = EasyMock.createMock(MediaInspectionService.class);
EasyMock.expect(mediaInspectionService.enrich(anyObject(), anyBoolean())).andReturn(job).once();
EasyMock.replay(animateService, workspace, workflow, mediaInspectionService);
handler.setAnimateService(animateService);
handler.setMediaInspectionService(mediaInspectionService);
handler.setWorkspace(workspace);
}
Aggregations