use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository in project pentaho-platform by pentaho.
the class DefaultDatasourceMgmtWebServiceTest method setUp.
public void setUp() throws Exception {
IUnifiedRepository repository = new MockUnifiedRepository(new MockUnifiedRepository.SpringSecurityCurrentUserProvider());
datasourceMgmtService = new JcrBackedDatasourceMgmtService(repository, new DatabaseDialectService());
datasourceMgmtWebService = new DefaultDatasourceMgmtWebService(datasourceMgmtService);
dbConnectionAdapter = new DatabaseConnectionAdapter();
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();
}
use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository in project pentaho-platform by pentaho.
the class RepositoryUtilsTest method testGetFolder.
@Test
public void testGetFolder() throws Exception {
final MockUnifiedRepository repository = new MockUnifiedRepository(new SpringSecurityCurrentUserProvider());
final RepositoryUtils repositoryUtils = new RepositoryUtils(repository);
RepositoryFile test = repositoryUtils.getFolder("/public/one/two/three", true, true, null);
assertNotNull(test);
assertEquals("The folder name is invalid", "three", test.getName());
assertEquals("The path is invalid", "/public/one/two/three", test.getPath());
assertTrue("The folder should 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 RepositoryFileImportFileHandlerTest method setup.
private void setup(String mimeTypeName, String extension, String path, String fileName, boolean folder) {
List<String> extensions = Arrays.asList(extension);
IMimeType mimeType = new MimeType(mimeTypeName, extensions);
mimeType.setConverter(mock(Converter.class));
List<IMimeType> mimeTypeList = Arrays.asList(mimeType);
NameBaseMimeResolver mimeResolver = new NameBaseMimeResolver();
mimeResolver.addMimeType(mimeType);
SolutionFileImportHelper.testMimeResolver = mimeResolver;
userProvider = new UserProvider();
mockRepository = new MockUnifiedRepository(userProvider);
fileHandler = new RepositoryFileImportFileHandler(mimeTypeList);
fileHandler.setRepository(mockRepository);
fileHandler.setDefaultAclHandler(new DefaultAclHandler());
fileHandler.setKnownExtensions(Arrays.asList("prpt"));
IPlatformImporter mockPlatformImporter = mock(IPlatformImporter.class);
when(mockPlatformImporter.getRepositoryImportLogger()).thenReturn(new Log4JRepositoryImportLogger());
ImportSession.iPlatformImporter = mockPlatformImporter;
importSession = fileHandler.getImportSession();
importSession.initialize();
mockBundle = mock(RepositoryFileImportBundle.class);
when(mockBundle.getPath()).thenReturn(path);
when(mockBundle.getName()).thenReturn(fileName);
when(mockBundle.getMimeType()).thenReturn(mimeTypeName);
when(mockBundle.isFolder()).thenReturn(folder);
}
use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository in project data-access by pentaho.
the class MetadataDatasourceServiceTest method setUp.
@Before
public void setUp() throws Exception {
Mockery context = new JUnit4Mockery();
manager = new MockBackingRepositoryLifecycleManager(new MockSecurityHelper());
booter = new MicroPlatform("test-res");
// Clear up the cache
final ICacheManager cacheMgr = PentahoSystem.getCacheManager(null);
cacheMgr.clearRegionCache(MondrianCatalogHelper.MONDRIAN_CATALOG_CACHE_REGION);
// Define a repository for testing
repository = new MockUnifiedRepository(new MockUserProvider());
repository.createFolder(repository.getFile("/etc").getId(), new RepositoryFile.Builder("metadata").folder(true).build(), "initialization");
final IAuthorizationPolicy policy = context.mock(IAuthorizationPolicy.class);
booter.defineInstance(IAuthorizationPolicy.class, policy);
booter.defineInstance(IUnifiedRepository.class, repository);
booter.start();
logout();
manager.startup();
context.checking(new Expectations() {
{
oneOf(policy);
will(returnValue(true));
oneOf(policy);
will(returnValue(true));
oneOf(policy);
will(returnValue(true));
}
});
}
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