use of org.opencastproject.serviceregistry.api.ServiceRegistry 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.serviceregistry.api.ServiceRegistry 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.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class TimelinePreviewsServiceImplTest method testUpdated.
/**
* Test of updated method of class TimelinePreviewsServiceImpl.
* @throws java.lang.Exception
*/
@Test
public void testUpdated() throws Exception {
Dictionary<String, String> properties = new Hashtable<>();
properties.put(TimelinePreviewsServiceImpl.OPT_RESOLUTION_X, "200");
properties.put(TimelinePreviewsServiceImpl.OPT_RESOLUTION_Y, "90");
properties.put(TimelinePreviewsServiceImpl.OPT_OUTPUT_FORMAT, ".jpg");
properties.put(TimelinePreviewsServiceImpl.OPT_MIMETYPE, "image/jpg");
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.getHostRegistrations()).andReturn(new ArrayList());
EasyMock.replay(serviceRegistry);
TimelinePreviewsServiceImpl instance = new TimelinePreviewsServiceImpl();
instance.setServiceRegistry(serviceRegistry);
try {
instance.updated(properties);
// we cannot check private fields but it should not throw any exception
assertEquals(200, instance.resolutionX);
assertEquals(90, instance.resolutionY);
assertEquals(".jpg", instance.outputFormat);
assertEquals("image/jpg", instance.mimetype);
} catch (Exception e) {
fail("updated method should not throw any exceptions but has thrown: " + ExceptionUtils.getStackTrace(e));
}
}
use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class StartTranscriptionOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
// Media package set up
URI mediaPackageURI = StartTranscriptionOperationHandlerTest.class.getResource("/mp.xml").toURI();
mediaPackage = builder.loadFromXml(mediaPackageURI.toURL().openStream());
// Service registry set up
Job job1 = EasyMock.createNiceMock(Job.class);
EasyMock.expect(job1.getId()).andReturn(1L);
EasyMock.expect(job1.getPayload()).andReturn(null).anyTimes();
EasyMock.expect(job1.getStatus()).andReturn(Job.Status.FINISHED);
EasyMock.expect(job1.getDateCreated()).andReturn(new Date());
EasyMock.expect(job1.getDateStarted()).andReturn(new Date());
EasyMock.expect(job1.getQueueTime()).andReturn(new Long(0));
EasyMock.replay(job1);
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job1);
EasyMock.replay(serviceRegistry);
// Transcription service set up
service = EasyMock.createStrictMock(TranscriptionService.class);
capturedTrack = Capture.newInstance();
EasyMock.expect(service.startTranscription(EasyMock.anyObject(String.class), EasyMock.capture(capturedTrack))).andReturn(null);
EasyMock.replay(service);
// Workflow set up
WorkflowDefinitionImpl def = new WorkflowDefinitionImpl();
def.setId("DCE-start-transcription");
def.setPublished(true);
workflowInstance = new WorkflowInstanceImpl(def, mediaPackage, null, null, null, null);
workflowInstance.setId(1);
operation = new WorkflowOperationInstanceImpl("start-transcript", OperationState.RUNNING);
List<WorkflowOperationInstance> operationList = new ArrayList<WorkflowOperationInstance>();
operationList.add(operation);
workflowInstance.setOperations(operationList);
// Operation handler set up
operationHandler = new StartTranscriptionOperationHandler();
operationHandler.setTranscriptionService(service);
operationHandler.setServiceRegistry(serviceRegistry);
}
use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class OaiPmhPublicationRestServiceTest method testPublishUsingRemoteService.
@Test
public void testPublishUsingRemoteService() throws Exception {
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mp.addCreator(CREATOR);
//
final ServiceRegistry registry = EasyMock.createNiceMock(ServiceRegistry.class);
final ServiceRegistration registration = EasyMock.createNiceMock(ServiceRegistration.class);
EasyMock.expect(registration.getHost()).andReturn(url.getProtocol() + "://" + url.getHost() + ":" + url.getPort()).anyTimes();
EasyMock.expect(registration.getPath()).andReturn(url.getPath()).anyTimes();
EasyMock.expect(registry.getServiceRegistrationsByLoad(EasyMock.anyString())).andReturn(ListBuilders.SIA.mk(registration)).anyTimes();
EasyMock.replay(registry, registration);
final OaiPmhPublicationServiceRemoteImpl remote = new OaiPmhPublicationServiceRemoteImpl();
remote.setTrustedHttpClient(new TestHttpClient());
remote.setRemoteServiceManager(registry);
//
final Job job = remote.publish(mp, "mmp", new HashSet<String>(), new HashSet<String>(), false);
assertEquals(job.getUri(), JOB_URI);
}
Aggregations