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;
}
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);
}
}
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());
}
}
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());
}
}
Aggregations