use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository in project pentaho-platform by pentaho.
the class RepositoryUtilsTest method testGetFile.
@Test
public void testGetFile() throws Exception {
final MockUnifiedRepository repository = new MockUnifiedRepository(new SpringSecurityCurrentUserProvider());
final RepositoryUtils repositoryUtils = new RepositoryUtils(repository);
final SimpleRepositoryFileData data = new SimpleRepositoryFileData(new ByteArrayInputStream("Test".getBytes()), "UTF-8", "text/plain");
RepositoryFile test = repositoryUtils.getFile("/public/one/two/three.prpt", data, true, true, null);
assertNotNull(test);
assertEquals("The filename is invalid", "three.prpt", test.getName());
assertEquals("The path is invalid", "/public/one/two/three.prpt", test.getPath());
assertFalse("The file should not be defined as a folder", test.isFolder());
// Make sure it created the parents
RepositoryFile one = repositoryUtils.getFolder("/public/one", false, false, null);
assertNotNull(one);
RepositoryFile two = repositoryUtils.getFolder("/public/one/two", false, false, null);
assertNotNull(two);
}
use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository in project pentaho-platform by pentaho.
the class DatasourceMgmtToWebServiceAdapterTest method setUp.
@Override
protected void setUp() throws Exception {
IUnifiedRepository repository = new MockUnifiedRepository(new MockUnifiedRepository.SpringSecurityCurrentUserProvider());
datasourceMgmtService = new JcrBackedDatasourceMgmtService(repository, new DatabaseDialectService());
datasourceMgmtWS = new DefaultDatasourceMgmtWebService(datasourceMgmtService);
adapter = new DatasourceMgmtToWebServiceAdapter(datasourceMgmtWS);
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(MockUnifiedRepository.root().getName(), null, new ArrayList<GrantedAuthority>()));
repository.createFolder(repository.getFile("/etc").getId(), new RepositoryFile.Builder(FOLDER_PDI).folder(true).build(), new RepositoryFileAcl.Builder(MockUnifiedRepository.root()).ace(MockUnifiedRepository.everyone(), READ, WRITE).build(), null);
repository.createFolder(repository.getFile("/etc/pdi").getId(), new RepositoryFile.Builder(FOLDER_DATABASES).folder(true).build(), null);
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(EXP_LOGIN, null, new ArrayList<GrantedAuthority>()));
KettleClientEnvironment.init();
}
Aggregations