use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class JaxWsSchedulerServiceIT method init.
@Before
public void init() throws SchedulerException, PlatformInitializationException {
schedulerSvc = (ISchedulerService) applicationContext.getBean("schedulerFromWs");
MicroPlatform mp = new MicroPlatform();
mp.define(IPluginManager.class, TstPluginManager.class);
mp.define("IScheduler2", TestQuartzScheduler.class);
mp.define(IUserRoleListService.class, StubUserRoleListService.class);
mp.define(UserDetailsService.class, StubUserDetailsService.class);
mp.start();
scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
scheduler.start();
MyAction.executed = false;
MyAction.staticStringParam = null;
jobParams = new HashMap<String, ParamValue>();
jobParams.put("stringParam", new StringParamValue("testStringValue"));
RUN_ONCE_IN_2_SECS = JobTrigger.ONCE_NOW;
RUN_ONCE_IN_2_SECS.setStartTime(new Date(System.currentTimeMillis() + 2000L));
RUN_ONCE_IN_3_SECS = JobTrigger.ONCE_NOW;
RUN_ONCE_IN_3_SECS.setStartTime(new Date(System.currentTimeMillis() + 2000L));
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class ZipExportProcessorTest method init.
@Before
public void init() throws IOException, PlatformInitializationException, DomainIdNullException, DomainAlreadyExistsException, DomainStorageException {
List<Locale> availableLocales = java.util.Collections.singletonList(LOCALE_DEFAULT);
Properties localePropertries = new Properties();
localePropertries.setProperty("name1", "value1");
final RepositoryFile file0 = new RepositoryFile.Builder("").path("/").id("/").folder(true).build();
final RepositoryFile file1 = new RepositoryFile.Builder("home").path("/home/").id("/home/").folder(true).build();
final RepositoryFile file2 = new RepositoryFile.Builder("test user").path("/home/test user/").id("/home/test user/").folder(true).build();
final RepositoryFile file3 = new RepositoryFile.Builder("two words").path("/home/test user/two words/").id("/home/test user/two words/").folder(true).build();
final RepositoryFile fileX = new RepositoryFile.Builder("eval (+)%.prpt").path("/home/test user/two words/eval (+)%.prpt").id("/home/test user/two words/eval (+)%.prpt").folder(false).build();
final RepositoryFile[] repoFiles = new RepositoryFile[] { file0, file1, file2, file3, fileX };
final Map<Serializable, RepositoryFile> repoFilesMap = new HashMap<Serializable, RepositoryFile>();
for (RepositoryFile f : repoFiles) {
repoFilesMap.put(f.getId(), f);
}
repo = mock(IUnifiedRepository.class);
final Answer<RepositoryFile> answerRepoGetFile = new Answer<RepositoryFile>() {
@Override
public RepositoryFile answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
final Object fileId = args[0];
return getRepoFile(repoFilesMap, fileId);
}
};
Mockito.doAnswer(answerRepoGetFile).when(repo).getFile(anyString());
Mockito.doAnswer(answerRepoGetFile).when(repo).getFile(anyString(), Mockito.anyBoolean());
Mockito.doAnswer(answerRepoGetFile).when(repo).getFile(anyString(), Mockito.anyBoolean(), any(IPentahoLocale.class));
Mockito.doAnswer(answerRepoGetFile).when(repo).getFile(anyString(), any(IPentahoLocale.class));
Mockito.doAnswer(answerRepoGetFile).when(repo).getFileById(any(Serializable.class));
Mockito.doAnswer(answerRepoGetFile).when(repo).getFileById(any(Serializable.class), Mockito.anyBoolean());
Mockito.doAnswer(answerRepoGetFile).when(repo).getFileById(any(Serializable.class), Mockito.anyBoolean(), any(IPentahoLocale.class));
Mockito.doAnswer(answerRepoGetFile).when(repo).getFileById(any(Serializable.class), any(IPentahoLocale.class));
Answer<List<RepositoryFile>> answerRepoGetChildren = new Answer<List<RepositoryFile>>() {
@Override
public List<RepositoryFile> answer(InvocationOnMock invocation) throws Throwable {
// returns the following item from <repoFiles>
RepositoryRequest r = (RepositoryRequest) invocation.getArguments()[0];
String path = r.getPath();
RepositoryFile thisFile = getRepoFile(repoFilesMap, path);
if (thisFile == null || !thisFile.isFolder()) {
return Collections.emptyList();
}
for (int i = 0, n = repoFiles.length - 1; i < n; i++) {
RepositoryFile iFile = repoFiles[i];
if (iFile == thisFile || iFile.getId().equals(thisFile.getId())) {
return Collections.singletonList(repoFiles[i + 1]);
}
}
return Collections.emptyList();
}
};
Mockito.doAnswer(answerRepoGetChildren).when(repo).getChildren(any(RepositoryRequest.class));
doReturn(availableLocales).when(repo).getAvailableLocalesForFile(Mockito.any(RepositoryFile.class));
doReturn(availableLocales).when(repo).getAvailableLocalesForFileById(Mockito.any(Serializable.class));
doReturn(availableLocales).when(repo).getAvailableLocalesForFileByPath(Mockito.any(String.class));
doReturn(localePropertries).when(repo).getLocalePropertiesForFileById(Mockito.any(File.class), Mockito.anyString());
RepositoryFileSid sid = mock(RepositoryFileSid.class);
doReturn("testUser").when(sid).getName();
doReturn(Type.USER).when(sid).getType();
final RepositoryFileAcl mockAcl = mock(RepositoryFileAcl.class);
doReturn(sid).when(mockAcl).getOwner();
doReturn(mockAcl).when(repo).getAcl(any(Serializable.class));
Answer<IRepositoryFileData> answerGetDataForRead = new Answer<IRepositoryFileData>() {
@Override
public IRepositoryFileData answer(InvocationOnMock invocation) throws Throwable {
Serializable id = (Serializable) invocation.getArguments()[0];
RepositoryFile file = getRepoFile(repoFilesMap, id);
if (!file.isFolder()) {
return new SimpleRepositoryFileData(new ByteArrayInputStream(new byte[0]), "UTF-8", MIME_PRPT.getName());
}
return null;
}
};
doAnswer(answerGetDataForRead).when(repo).getDataForRead(Mockito.any(Serializable.class), Mockito.any(Class.class));
exportHandler = new DefaultExportHandler();
defaultConverter = new StreamConverter(repo);
PentahoSystem.clearObjectFactory();
microPlatform = new MicroPlatform(getSolutionPath());
microPlatform.defineInstance(IUnifiedRepository.class, repo);
// microPlatform.defineInstance( IPlatformMimeResolver.class, mimeResolver );
microPlatform.defineInstance(ISolutionEngine.class, Mockito.mock(SolutionEngine.class));
microPlatform.defineInstance(IDatasourceMgmtService.class, Mockito.mock(IDatasourceMgmtService.class));
microPlatform.start();
exportSession = new StandaloneSession();
PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
PentahoSessionHolder.setSession(exportSession);
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class DirectoryResourceIT method beforeTest.
@Before
public void beforeTest() throws PlatformInitializationException {
mp = new MicroPlatform();
// used by DefaultPentahoJackrabbitAccessControlHelper
mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
mp.defineInstance(ITenantManager.class, tenantManager);
mp.define(ITenant.class, Tenant.class);
mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
mp.defineInstance(IRoleAuthorizationPolicyRoleBindingDao.class, roleBindingDaoTarget);
mp.defineInstance("tenantedUserNameUtils", tenantedUserNameUtils);
mp.defineInstance("tenantedRoleNameUtils", tenantedRoleNameUtils);
mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
mp.define(IRoleAuthorizationPolicyRoleBindingDao.class, RoleAuthorizationPolicy.class, Scope.GLOBAL);
mp.define(ITenantManager.class, RepositoryTenantManager.class, Scope.GLOBAL);
mp.defineInstance("singleTenantAdminAuthorityName", new String("Administrator"));
mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(this.testJcrTemplate, this.repositoryFileDao));
DefaultRepositoryVersionManager defaultRepositoryVersionManager = new DefaultRepositoryVersionManager();
defaultRepositoryVersionManager.setPlatformMimeResolver(new NameBaseMimeResolver());
mp.defineInstance(IRepositoryVersionManager.class, defaultRepositoryVersionManager);
UserRoleDaoUserDetailsService userDetailsService = new UserRoleDaoUserDetailsService();
userDetailsService.setUserRoleDao(userRoleDao);
List<String> systemRoles = new ArrayList<String>();
systemRoles.add("Admin");
List<String> extraRoles = Arrays.asList(new String[] { "Authenticated", "Anonymous" });
String adminRole = "Admin";
userRoleListService = new UserRoleDaoUserRoleListService(userRoleDao, userDetailsService, tenantedUserNameUtils, systemRoles, extraRoles, adminRole);
((UserRoleDaoUserRoleListService) userRoleListService).setUserRoleDao(userRoleDao);
((UserRoleDaoUserRoleListService) userRoleListService).setUserDetailsService(userDetailsService);
mp.defineInstance(IUserRoleListService.class, userRoleListService);
mp.start();
logout();
startupCalled = true;
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class ChartBeansSystemListenerIT method setUp.
/**
* @throws java.lang.Exception
*/
@SuppressWarnings("deprecation")
@Before
public void setUp() throws Exception {
String solutionsRelativePath = TestResourceLocation.TEST_RESOURCES + "/org/pentaho/test/platform/plugin/chartbeans/solutions";
MicroPlatform mp = new MicroPlatform(solutionsRelativePath);
mp.define(ISolutionEngine.class, Object.class);
ISystemSettings settings = new XmlSimpleSystemSettings();
mp.setSettingsProvider(settings);
mp.init();
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class DefaultPluginManagerIT method init0.
@Before
public void init0() {
PentahoSystem.clearObjectFactory();
microPlatform = new MicroPlatform(getSolutionPath());
microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
microPlatform.define(IPluginProvider.class, SystemPathXmlPluginProvider.class);
microPlatform.define(IServiceManager.class, DefaultServiceManager.class, Scope.GLOBAL);
microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
repo.setRootDir(new File(getSolutionPath()));
session = new StandaloneSession();
pluginManager = new DefaultPluginManager();
}
Aggregations