use of org.opencastproject.smil.entity.SmilImpl in project opencast by opencast.
the class SmilResponseImplTest method testXml.
/**
* Test of toXml and fromXml methods, of class SmilResponseImpl.
*/
@Test
public void testXml() throws Exception {
Smil smil = new SmilImpl();
SmilResponse response = new SmilResponseImpl(smil, new SmilObject[] { smil.getHead(), smil.getBody() });
try {
String xml = response.toXml();
// logger.info(xml);
assertNotNull(xml);
// test xml contains smil element
assertTrue(xml.contains("<smil"));
// test xml contains head entity
assertTrue(xml.contains("entity><head"));
// test xml contains body entity
assertTrue(xml.contains("entity><body"));
SmilResponse responseUnmarshalled = SmilResponseImpl.fromXml(xml);
assertNotNull(responseUnmarshalled);
// test smil object id
assertEquals(response.getSmil().getId(), responseUnmarshalled.getSmil().getId());
// test entities
assertSame(response.getEntitiesCount(), responseUnmarshalled.getEntitiesCount());
assertEquals(response.getEntities()[0].getId(), responseUnmarshalled.getEntities()[0].getId());
assertEquals(response.getEntities()[1].getId(), responseUnmarshalled.getEntities()[1].getId());
} catch (JAXBException ex) {
fail("can't (de-)serialize SmilResponse");
}
}
use of org.opencastproject.smil.entity.SmilImpl in project opencast by opencast.
the class SmilResponseImplTest method testGetSmil.
/**
* Test of getSmil method, of class SmilResponseImpl.
*/
@Test
public void testGetSmil() {
Smil smil = new SmilImpl();
SmilResponse response = new SmilResponseImpl(smil);
assertEquals(smil, response.getSmil());
}
use of org.opencastproject.smil.entity.SmilImpl in project opencast by opencast.
the class SmilResponseImplTest method testGetEntities.
/**
* Test of getEntities method, of class SmilResponseImpl.
*/
@Test
public void testGetEntities() throws Exception {
Smil smil = new SmilImpl();
SmilResponse response = new SmilResponseImpl(smil);
try {
response.getEntities();
fail("getEntities should fail, if entity count is zero");
} catch (SmilException ex) {
}
response = new SmilResponseImpl(smil, smil.getBody());
try {
SmilObject[] entities = response.getEntities();
assertSame(1, entities.length);
assertSame(smil.getBody(), entities[0]);
} catch (SmilException ex) {
fail("getEntities should not throw an Exception if some entities are set");
}
response = new SmilResponseImpl(smil, new SmilObject[] { smil.getHead(), smil.getBody() });
try {
SmilObject[] entities = response.getEntities();
assertSame(2, entities.length);
assertSame(smil.getHead(), entities[0]);
assertSame(smil.getBody(), entities[1]);
} catch (SmilException ex) {
fail("getEntities should not throw an Exception if some entities are set");
}
}
use of org.opencastproject.smil.entity.SmilImpl in project opencast by opencast.
the class SmilServiceImpl method createNewSmil.
/**
* {@inheritDoc}
*/
@Override
public SmilResponse createNewSmil(MediaPackage mediaPackage) {
SmilImpl smil = new SmilImpl();
((SmilHeadImpl) smil.getHead()).addMeta(SmilMeta.SMIL_META_NAME_MEDIA_PACKAGE_ID, mediaPackage.getIdentifier().compact());
return new SmilResponseImpl(smil);
}
use of org.opencastproject.smil.entity.SmilImpl 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());
}
Aggregations