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