Search in sources :

Example 1 with MediaPackageBuilderFactory

use of org.opencastproject.mediapackage.MediaPackageBuilderFactory in project opencast by opencast.

the class SearchServiceImplTest method getMediaPackage.

private MediaPackage getMediaPackage(String path) throws MediaPackageException {
    MediaPackageBuilderFactory builderFactory = MediaPackageBuilderFactory.newInstance();
    MediaPackageBuilder mediaPackageBuilder = builderFactory.newMediaPackageBuilder();
    URL rootUrl = SearchServiceImplTest.class.getResource("/");
    mediaPackageBuilder.setSerializer(new DefaultMediaPackageSerializerImpl(rootUrl));
    // Load the simple media package
    MediaPackage mediaPackage = null;
    InputStream is = null;
    try {
        is = SearchServiceImplTest.class.getResourceAsStream(path);
        mediaPackage = mediaPackageBuilder.loadFromXml(is);
    } finally {
        IOUtils.closeQuietly(is);
    }
    return mediaPackage;
}
Also used : DefaultMediaPackageSerializerImpl(org.opencastproject.mediapackage.DefaultMediaPackageSerializerImpl) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) InputStream(java.io.InputStream) MediaPackage(org.opencastproject.mediapackage.MediaPackage) MediaPackageBuilderFactory(org.opencastproject.mediapackage.MediaPackageBuilderFactory) URL(java.net.URL)

Example 2 with MediaPackageBuilderFactory

use of org.opencastproject.mediapackage.MediaPackageBuilderFactory in project opencast by opencast.

the class StaticMetadataServiceDublinCoreImplTest method newMediaPackage.

private MediaPackage newMediaPackage(String manifest) throws Exception {
    MediaPackageBuilderFactory builderFactory = MediaPackageBuilderFactory.newInstance();
    MediaPackageBuilder mediaPackageBuilder = builderFactory.newMediaPackageBuilder();
    URL rootUrl = getClass().getResource("/");
    mediaPackageBuilder.setSerializer(new DefaultMediaPackageSerializerImpl(rootUrl));
    InputStream is = null;
    try {
        is = getClass().getResourceAsStream(manifest);
        return mediaPackageBuilder.loadFromXml(is);
    } finally {
        IOUtils.closeQuietly(is);
    }
}
Also used : DefaultMediaPackageSerializerImpl(org.opencastproject.mediapackage.DefaultMediaPackageSerializerImpl) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) InputStream(java.io.InputStream) MediaPackageBuilderFactory(org.opencastproject.mediapackage.MediaPackageBuilderFactory) URL(java.net.URL)

Example 3 with MediaPackageBuilderFactory

use of org.opencastproject.mediapackage.MediaPackageBuilderFactory 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 4 with MediaPackageBuilderFactory

use of org.opencastproject.mediapackage.MediaPackageBuilderFactory 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)

Aggregations

MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)4 MediaPackageBuilderFactory (org.opencastproject.mediapackage.MediaPackageBuilderFactory)4 MediaPackage (org.opencastproject.mediapackage.MediaPackage)3 InputStream (java.io.InputStream)2 URL (java.net.URL)2 Test (org.junit.Test)2 DefaultMediaPackageSerializerImpl (org.opencastproject.mediapackage.DefaultMediaPackageSerializerImpl)2 IdImpl (org.opencastproject.mediapackage.identifier.IdImpl)2 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)2