Search in sources :

Example 1 with SmilImpl

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");
    }
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilImpl(org.opencastproject.smil.entity.SmilImpl) JAXBException(javax.xml.bind.JAXBException) Smil(org.opencastproject.smil.entity.api.Smil) Test(org.junit.Test)

Example 2 with SmilImpl

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());
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilImpl(org.opencastproject.smil.entity.SmilImpl) Smil(org.opencastproject.smil.entity.api.Smil) Test(org.junit.Test)

Example 3 with SmilImpl

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");
    }
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilImpl(org.opencastproject.smil.entity.SmilImpl) SmilObject(org.opencastproject.smil.entity.api.SmilObject) Smil(org.opencastproject.smil.entity.api.Smil) SmilException(org.opencastproject.smil.api.SmilException) Test(org.junit.Test)

Example 4 with SmilImpl

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);
}
Also used : SmilHeadImpl(org.opencastproject.smil.entity.SmilHeadImpl) SmilImpl(org.opencastproject.smil.entity.SmilImpl)

Example 5 with SmilImpl

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());
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilImpl(org.opencastproject.smil.entity.SmilImpl) SmilObject(org.opencastproject.smil.entity.api.SmilObject) Smil(org.opencastproject.smil.entity.api.Smil) Test(org.junit.Test)

Aggregations

SmilImpl (org.opencastproject.smil.entity.SmilImpl)6 Test (org.junit.Test)5 SmilResponse (org.opencastproject.smil.api.SmilResponse)5 Smil (org.opencastproject.smil.entity.api.Smil)5 SmilObject (org.opencastproject.smil.entity.api.SmilObject)3 SmilException (org.opencastproject.smil.api.SmilException)2 JAXBException (javax.xml.bind.JAXBException)1 SmilHeadImpl (org.opencastproject.smil.entity.SmilHeadImpl)1