use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class ServersListProviderTest method setUp.
@Before
public void setUp() throws Exception {
this.serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
serverListProvider = new ServersListProvider();
List<HostRegistration> hosts = new ArrayList<HostRegistration>();
hosts.add(new JaxbHostRegistration(HOST1, "1.1.1.1", 400000, 8, 8, true, false));
hosts.add(new JaxbHostRegistration(HOST2, "1.1.1.2", 400000, 8, 8, true, true));
hosts.add(new JaxbHostRegistration(HOST3, "1.1.1.3", 500000, 2, 8, false, false));
hosts.add(new JaxbHostRegistration(HOST4, "1.1.1.4", 500000, 6, 8, true, true));
EasyMock.expect(serviceRegistry.getHostRegistrations()).andReturn(hosts).anyTimes();
serverListProvider.setServiceRegistry(serviceRegistry);
serverListProvider.activate(null);
EasyMock.replay(serviceRegistry);
}
use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class JobUtilTest method setUp.
@Before
public void setUp() throws Exception {
serviceRegistry = createNiceMock(ServiceRegistry.class);
JobImpl job = new JobImpl(20);
job.setPayload("a payload");
Job finishedJob1 = new JobImpl(1);
finishedJob1.setStatus(Status.FINISHED);
Job finishedJob2 = new JobImpl(2);
finishedJob2.setStatus(Status.FINISHED);
Job finishedJob3 = new JobImpl(3);
finishedJob3.setStatus(Status.FINISHED);
expect(serviceRegistry.getJob(1)).andReturn(finishedJob1).anyTimes();
expect(serviceRegistry.getJob(2)).andReturn(finishedJob2).anyTimes();
expect(serviceRegistry.getJob(3)).andReturn(finishedJob3).anyTimes();
expect(serviceRegistry.getJob(23)).andThrow(new NotFoundException()).anyTimes();
expect(serviceRegistry.getJob(20)).andReturn(job).anyTimes();
replay(serviceRegistry);
}
use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class OsgiIncidentServiceTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
final EntityManagerFactory emf = PersistenceUtil.newTestEntityManagerFactory(AbstractIncidentService.PERSISTENCE_UNIT_NAME);
penv = PersistenceEnvs.persistenceEnvironment(emf);
// Mock up a job
Job job = createNiceMock(Job.class);
expect(job.getProcessingHost()).andStubReturn(PROCESSING_HOST);
expect(job.getJobType()).andStubReturn(JOB_TYPE);
expect(job.getCreator()).andStubReturn("creator");
expect(job.getOrganization()).andStubReturn("organization");
replay(job);
// Mock up a service registry
final ServiceRegistry serviceRegistry = createNiceMock(ServiceRegistry.class);
expect(serviceRegistry.getJob(EasyMock.anyLong())).andAnswer(new IAnswer<Job>() {
@Override
public Job answer() throws Throwable {
final Long jobId = (Long) EasyMock.getCurrentArguments()[0];
return jobs.get(jobId);
}
}).anyTimes();
replay(serviceRegistry);
// Mock up a workflow service
final WorkflowService workflowService = createNiceMock(WorkflowService.class);
replay(workflowService);
incidentService = new AbstractIncidentService() {
@Override
protected ServiceRegistry getServiceRegistry() {
return serviceRegistry;
}
@Override
protected WorkflowService getWorkflowService() {
return workflowService;
}
@Override
protected PersistenceEnv getPenv() {
return PersistenceEnvs.persistenceEnvironment(emf);
}
};
incidents = new Incidents(serviceRegistry, incidentService);
}
use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class SearchServiceImplTest method testPopulateIndex.
@SuppressWarnings("unchecked")
@Test
public void testPopulateIndex() throws Exception {
// This service registry must return a list of jobs
List<String> args = new ArrayList<String>();
args.add(new DefaultOrganization().getId());
List<Job> jobs = new ArrayList<Job>();
for (long i = 0; i < 10; i++) {
MediaPackage mediaPackage = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mediaPackage.setIdentifier(IdBuilderFactory.newInstance().newIdBuilder().createNew());
searchDatabase.storeMediaPackage(mediaPackage, acl, new Date());
String payload = MediaPackageParser.getAsXml(mediaPackage);
Job job = new JobImpl(i);
job.setArguments(args);
job.setPayload(payload);
job.setStatus(Status.FINISHED);
jobs.add(job);
}
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.createJob((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (List<String>) EasyMock.anyObject(), (String) EasyMock.anyObject(), EasyMock.anyBoolean())).andReturn(new JobImpl()).anyTimes();
EasyMock.expect(serviceRegistry.updateJob((Job) EasyMock.anyObject())).andReturn(new JobImpl()).anyTimes();
EasyMock.expect(serviceRegistry.getJobs((String) EasyMock.anyObject(), (Status) EasyMock.anyObject())).andReturn(jobs).anyTimes();
EasyMock.replay(serviceRegistry);
service.setServiceRegistry(serviceRegistry);
OrganizationDirectoryService orgDirectory = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgDirectory.getOrganization((String) EasyMock.anyObject())).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(orgDirectory);
service.setOrganizationDirectoryService(orgDirectory);
// We should have nothing in the search index
assertEquals(0, service.getByQuery(new SearchQuery()).size());
service.populateIndex("System Admin");
// This time we should have 10 results
assertEquals(10, service.getByQuery(new SearchQuery()).size());
}
use of org.opencastproject.serviceregistry.api.ServiceRegistry in project opencast by opencast.
the class ComposeWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
// test resources
URI uriMP = InspectWorkflowOperationHandler.class.getResource("/compose_mediapackage.xml").toURI();
URI uriMPEncode = InspectWorkflowOperationHandler.class.getResource("/compose_encode_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
mpEncode = builder.loadFromXml(uriMPEncode.toURL().openStream());
encodedTracks = mpEncode.getTracks();
// set up mock workspace
workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.moveTo((URI) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(uriMP);
EasyMock.replay(workspace);
// set up mock receipt
job = EasyMock.createNiceMock(Job.class);
EasyMock.expect(job.getPayload()).andReturn(MediaPackageElementParser.getAsXml(encodedTracks[0])).anyTimes();
EasyMock.expect(job.getStatus()).andReturn(Job.Status.FINISHED);
EasyMock.expect(job.getDateCreated()).andReturn(new Date());
EasyMock.expect(job.getDateStarted()).andReturn(new Date());
EasyMock.expect(job.getQueueTime()).andReturn(new Long(0));
EasyMock.replay(job);
// set up mock service registry
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.getJob(EasyMock.anyLong())).andReturn(job);
EasyMock.replay(serviceRegistry);
// set up service
operationHandler = new ComposeWorkflowOperationHandler();
operationHandler.setJobBarrierPollingInterval(0);
operationHandler.setWorkspace(workspace);
operationHandler.setServiceRegistry(serviceRegistry);
}
Aggregations