Search in sources :

Example 1 with OaiPmhPublicationServiceRemoteImpl

use of org.opencastproject.publication.oaipmh.remote.OaiPmhPublicationServiceRemoteImpl 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);
}
Also used : OaiPmhPublicationServiceRemoteImpl(org.opencastproject.publication.oaipmh.remote.OaiPmhPublicationServiceRemoteImpl) MediaPackage(org.opencastproject.mediapackage.MediaPackage) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) ServiceRegistration(org.opencastproject.serviceregistry.api.ServiceRegistration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Job (org.opencastproject.job.api.Job)1 MediaPackage (org.opencastproject.mediapackage.MediaPackage)1 OaiPmhPublicationServiceRemoteImpl (org.opencastproject.publication.oaipmh.remote.OaiPmhPublicationServiceRemoteImpl)1 ServiceRegistration (org.opencastproject.serviceregistry.api.ServiceRegistration)1 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)1