Search in sources :

Example 1 with SeriesServiceDatabaseImpl

use of org.opencastproject.series.impl.persistence.SeriesServiceDatabaseImpl in project opencast by opencast.

the class SeriesServiceImplTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    long currentTime = System.currentTimeMillis();
    // Mock up a security service
    SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
    User user = new JaxbUser("admin", "test", new DefaultOrganization(), new JaxbRole(SecurityConstants.GLOBAL_ADMIN_ROLE, new DefaultOrganization()));
    EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
    EasyMock.expect(securityService.getUser()).andReturn(user).anyTimes();
    EasyMock.replay(securityService);
    seriesDatabase = new SeriesServiceDatabaseImpl();
    seriesDatabase.setEntityManagerFactory(newTestEntityManagerFactory(SeriesServiceDatabaseImpl.PERSISTENCE_UNIT));
    dcService = new DublinCoreCatalogService();
    seriesDatabase.setDublinCoreService(dcService);
    seriesDatabase.activate(null);
    seriesDatabase.setSecurityService(securityService);
    root = PathSupport.concat("target", Long.toString(currentTime));
    index = new SeriesServiceSolrIndex(root);
    index.setDublinCoreService(dcService);
    index.setSecurityService(securityService);
    index.activate(null);
    MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
    EasyMock.replay(messageSender);
    seriesService = new SeriesServiceImpl();
    seriesService.setPersistence(seriesDatabase);
    seriesService.setIndex(index);
    seriesService.setSecurityService(securityService);
    seriesService.setMessageSender(messageSender);
    BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
    EasyMock.expect(bundleContext.getProperty((String) EasyMock.anyObject())).andReturn("System Admin");
    EasyMock.replay(bundleContext);
    ComponentContext componentContext = EasyMock.createNiceMock(ComponentContext.class);
    EasyMock.expect(componentContext.getBundleContext()).andReturn(bundleContext).anyTimes();
    EasyMock.replay(componentContext);
    seriesService.activate(componentContext);
    InputStream in = null;
    try {
        in = getClass().getResourceAsStream("/dublincore.xml");
        testCatalog = dcService.load(in);
    } finally {
        IOUtils.closeQuietly(in);
    }
    try {
        in = getClass().getResourceAsStream("/dublincore2.xml");
        testCatalog2 = dcService.load(in);
    } finally {
        IOUtils.closeQuietly(in);
    }
}
Also used : User(org.opencastproject.security.api.User) JaxbUser(org.opencastproject.security.api.JaxbUser) ComponentContext(org.osgi.service.component.ComponentContext) MessageSender(org.opencastproject.message.broker.api.MessageSender) InputStream(java.io.InputStream) SeriesServiceDatabaseImpl(org.opencastproject.series.impl.persistence.SeriesServiceDatabaseImpl) JaxbUser(org.opencastproject.security.api.JaxbUser) DublinCoreCatalogService(org.opencastproject.metadata.dublincore.DublinCoreCatalogService) JaxbRole(org.opencastproject.security.api.JaxbRole) SecurityService(org.opencastproject.security.api.SecurityService) SeriesServiceSolrIndex(org.opencastproject.series.impl.solr.SeriesServiceSolrIndex) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Aggregations

InputStream (java.io.InputStream)1 Before (org.junit.Before)1 MessageSender (org.opencastproject.message.broker.api.MessageSender)1 DublinCoreCatalogService (org.opencastproject.metadata.dublincore.DublinCoreCatalogService)1 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)1 JaxbRole (org.opencastproject.security.api.JaxbRole)1 JaxbUser (org.opencastproject.security.api.JaxbUser)1 SecurityService (org.opencastproject.security.api.SecurityService)1 User (org.opencastproject.security.api.User)1 SeriesServiceDatabaseImpl (org.opencastproject.series.impl.persistence.SeriesServiceDatabaseImpl)1 SeriesServiceSolrIndex (org.opencastproject.series.impl.solr.SeriesServiceSolrIndex)1 BundleContext (org.osgi.framework.BundleContext)1 ComponentContext (org.osgi.service.component.ComponentContext)1