use of org.opencastproject.smil.entity.api.Smil in project opencast by opencast.
the class SmilServiceImplTest method testFromXml.
/**
* Test of fromXml methods, of class SmilServiceImpl.
*/
@Test
public void testFromXml() throws Exception {
SmilResponse smilResponse = smilService.fromXml(TEST_SMIL);
assertNotNull(smilResponse.getSmil());
Smil smil = smilResponse.getSmil();
// test head
assertSame(2, smil.getHead().getParamGroups().size());
// test body
assertSame(2, smil.getBody().getMediaElements().size());
assertTrue(smil.getBody().getMediaElements().get(0) instanceof SmilMediaParallelImpl);
assertTrue(smil.getBody().getMediaElements().get(1) instanceof SmilMediaParallelImpl);
SmilMediaContainer par = (SmilMediaContainer) smil.getBody().getMediaElements().get(0);
assertSame(2, par.getElements().size());
assertTrue(par.getElements().get(0) instanceof SmilMediaVideoImpl);
assertTrue(par.getElements().get(1) instanceof SmilMediaAudioImpl);
}
use of org.opencastproject.smil.entity.api.Smil in project opencast by opencast.
the class SmilResponseImplTest method testGetEntitiesCount.
/**
* Test of getEntitiesCount method, of class SmilResponseImpl.
*/
@Test
public void testGetEntitiesCount() {
Smil smil = new SmilImpl();
SmilResponse response = new SmilResponseImpl(smil);
assertSame(0, response.getEntitiesCount());
response = new SmilResponseImpl(smil, smil.getBody());
assertSame(1, response.getEntitiesCount());
response = new SmilResponseImpl(smil, new SmilObject[] { smil.getHead(), smil.getBody() });
assertSame(2, response.getEntitiesCount());
}
use of org.opencastproject.smil.entity.api.Smil in project opencast by opencast.
the class SmilResponseImplTest method testGetEntity.
/**
* Test of getEntity method, of class SmilResponseImpl.
*/
@Test
public void testGetEntity() throws Exception {
Smil smil = new SmilImpl();
SmilResponse response = new SmilResponseImpl(smil);
try {
response.getEntity();
fail("getEntity should fail, if entity count is zero");
} catch (SmilException ex) {
}
response = new SmilResponseImpl(smil, smil.getBody());
try {
assertSame(smil.getBody(), response.getEntity());
assertSame(1, response.getEntities().length);
assertSame(smil.getBody(), response.getEntities()[0]);
} catch (SmilException ex) {
fail("getEntity should return the entity");
}
response = new SmilResponseImpl(smil, new SmilObject[] { smil.getHead(), smil.getBody() });
try {
response.getEntity();
fail("get entity should fail if there are more then one entities set.");
} catch (SmilException ex) {
}
}
use of org.opencastproject.smil.entity.api.Smil in project opencast by opencast.
the class SmilImpl method fromXML.
/**
* Unmarshall a SMIL document from string.
*
* @param xml {@link Smil} document as xml
* @return parsed {@link Smil}
* @throws JAXBException if unmarshalling fail
*/
public static Smil fromXML(String xml) throws JAXBException {
JAXBContext jctx = JAXBContext.newInstance(SmilImpl.class);
Unmarshaller unmarshaller = jctx.createUnmarshaller();
return (Smil) unmarshaller.unmarshal(new StringReader(xml));
}
use of org.opencastproject.smil.entity.api.Smil in project opencast by opencast.
the class SmilImpl method fromXML.
/**
* Unmarshall a SMIL document from file.
*
* @param xmlFile {@link Smil} document as file
* @return parsed {@link Smil}
* @throws JAXBException if unmarshalling fail
*/
public static Smil fromXML(File xmlFile) throws JAXBException {
JAXBContext jctx = JAXBContext.newInstance(SmilImpl.class);
Unmarshaller unmarshaller = jctx.createUnmarshaller();
return (Smil) unmarshaller.unmarshal(xmlFile);
}
Aggregations