Search in sources :

Example 21 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class MediaPackagePostOperationHandlerTest method testHTTPPostXML.

@Test
public void testHTTPPostXML() throws Exception {
    // create a dummy mediapackage
    MediaPackageBuilderFactory factory = MediaPackageBuilderFactory.newInstance();
    MediaPackageBuilder builder = factory.newMediaPackageBuilder();
    MediaPackage mp = builder.createNew(new IdImpl("xyz"));
    mp.setTitle("test");
    mp.addContributor("lkiesow");
    mp.addContributor("lkiesow");
    /* Sending stuff to port 9 shound never return anything as the Discard
     * Protocol uses port 9 */
    InstanceAndHandler tuple = createWorkflow("http://127.0.0.1:9", "xml");
    MediaPackagePostOperationHandler handler = (MediaPackagePostOperationHandler) tuple.workflowHandler;
    tuple.workflowInstance.setMediaPackage(mp);
    try {
        tuple.workflowHandler.start(tuple.workflowInstance, null);
        /* This should raise an exception. Something is wrong if not. */
        Assert.fail();
    } catch (WorkflowOperationException e) {
        logger.info(e.toString());
    }
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) MediaPackageBuilderFactory(org.opencastproject.mediapackage.MediaPackageBuilderFactory) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Test(org.junit.Test)

Example 22 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class MediaPackagePostOperationHandlerTest method testHTTPPostJSON.

@Test
public void testHTTPPostJSON() throws Exception {
    // create a dummy mediapackage
    MediaPackageBuilderFactory factory = MediaPackageBuilderFactory.newInstance();
    MediaPackageBuilder builder = factory.newMediaPackageBuilder();
    MediaPackage mp = builder.createNew(new IdImpl("xyz"));
    mp.setTitle("test");
    mp.addContributor("lkiesow");
    mp.addContributor("lkiesow");
    /* Sending stuff to port 9 shound never return anything as the Discard
     * Protocol uses port 9 */
    InstanceAndHandler tuple = createWorkflow("http://127.0.0.1:9", "json");
    MediaPackagePostOperationHandler handler = (MediaPackagePostOperationHandler) tuple.workflowHandler;
    tuple.workflowInstance.setMediaPackage(mp);
    try {
        tuple.workflowHandler.start(tuple.workflowInstance, null);
        /* This should raise an exception. Something is wrong if not. */
        Assert.fail();
    } catch (WorkflowOperationException e) {
        logger.info(e.toString());
    }
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) MediaPackageBuilderFactory(org.opencastproject.mediapackage.MediaPackageBuilderFactory) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Test(org.junit.Test)

Example 23 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class ToolsEndpointTest method testAddSmilToArchive.

/**
 * Test method for {@link ToolsEndpoint#addSmilToArchive(org.opencastproject.mediapackage.MediaPackage, Smil)}
 */
@Test
public void testAddSmilToArchive() throws Exception {
    final String mpId = UUID.randomUUID().toString();
    final URI archiveElementURI = new URI("http://host.tld/archive/cut.smil");
    final String smilId = "s-afe311c6-9161-41f4-98d0-e951fe66d89e";
    Workspace workspace = createNiceMock(Workspace.class);
    expect(workspace.put(same(mpId), same(smilId), same("cut.smil"), anyObject(InputStream.class))).andReturn(archiveElementURI);
    replay(workspace);
    endpoint.setWorkspace(workspace);
    AssetManager assetManager = createNiceMock(AssetManager.class);
    replay(assetManager);
    endpoint.setAssetManager(assetManager);
    MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew(new IdImpl(mpId));
    endpoint.addSmilToArchive(mp, smil);
    assertEquals(1, mp.getCatalogs().length);
    assertEquals(smil.getId(), mp.getCatalogs()[0].getIdentifier());
    assertEquals("smil/cutting", mp.getCatalogs()[0].getFlavor().toString());
}
Also used : AssetManager(org.opencastproject.assetmanager.api.AssetManager) InputStream(java.io.InputStream) MediaPackage(org.opencastproject.mediapackage.MediaPackage) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Workspace(org.opencastproject.workspace.api.Workspace) Test(org.junit.Test)

Example 24 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class PublishEngageWorkflowOperationHandlerTest method testDefaultPlayerPath.

@Test
public void testDefaultPlayerPath() throws URISyntaxException {
    URI engageURI = new URI("http://engage.org");
    String mpId = "mp-id";
    MediaPackage mp = EasyMock.createNiceMock(MediaPackage.class);
    Id id = new IdImpl(mpId);
    EasyMock.expect(mp.getIdentifier()).andStubReturn(id);
    MediaPackageElement element = EasyMock.createNiceMock(MediaPackageElement.class);
    SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
    EasyMock.expect(securityService.getOrganization()).andReturn(getOrgWithoutPlayerPath()).once();
    EasyMock.replay(element, mp, securityService);
    // Test default player path
    PublishEngageWorkflowOperationHandler publishEngagePublish = new PublishEngageWorkflowOperationHandler();
    publishEngagePublish.setSecurityService(securityService);
    URI result = publishEngagePublish.createEngageUri(engageURI, mp);
    assertEquals(engageURI.toString() + PublishEngageWorkflowOperationHandler.DEFAULT_PLAYER_PATH + "?id=" + mpId, result.toString());
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) SecurityService(org.opencastproject.security.api.SecurityService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Test(org.junit.Test)

Example 25 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class PublishEngageWorkflowOperationHandlerTest method testPlayerUrl.

@Test
public void testPlayerUrl() throws WorkflowOperationException, URISyntaxException {
    URI engageURI = new URI("http://engage.org");
    String mpId = "mp-id";
    MediaPackage mp = EasyMock.createNiceMock(MediaPackage.class);
    Id id = new IdImpl(mpId);
    EasyMock.expect(mp.getIdentifier()).andStubReturn(id);
    MediaPackageElement element = EasyMock.createNiceMock(MediaPackageElement.class);
    SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
    EasyMock.expect(securityService.getOrganization()).andReturn(getOrgWithPlayerPath()).once();
    EasyMock.replay(element, mp, securityService);
    // Test configured organization player path
    PublishEngageWorkflowOperationHandler publishEngagePublish = new PublishEngageWorkflowOperationHandler();
    publishEngagePublish.setSecurityService(securityService);
    URI result = publishEngagePublish.createEngageUri(engageURI, mp);
    assertEquals(engageURI.toString() + examplePlayer + "?id=" + mpId, result.toString());
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) SecurityService(org.opencastproject.security.api.SecurityService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Test(org.junit.Test)

Aggregations

IdImpl (org.opencastproject.mediapackage.identifier.IdImpl)28 MediaPackage (org.opencastproject.mediapackage.MediaPackage)26 Test (org.junit.Test)21 URI (java.net.URI)13 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)12 SecurityService (org.opencastproject.security.api.SecurityService)11 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)9 Id (org.opencastproject.mediapackage.identifier.Id)9 InputStream (java.io.InputStream)8 Date (java.util.Date)7 Workspace (org.opencastproject.workspace.api.Workspace)7 Catalog (org.opencastproject.mediapackage.Catalog)6 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)6 AccessControlList (org.opencastproject.security.api.AccessControlList)6 ArrayList (java.util.ArrayList)5 Attachment (org.opencastproject.mediapackage.Attachment)5 HashMap (java.util.HashMap)4 NotFoundException (org.opencastproject.util.NotFoundException)4 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)4 HashSet (java.util.HashSet)3