use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.
the class PentahoMetadataDomainRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
// File tempDir = File.createTempFile("test", "");
// tempDir.delete();
// tempDir.mkdir();
// System.err.println("tempDir = " + tempDir.getAbsolutePath());
// repository = new FileSystemBackedUnifiedRepository(tempDir);
// new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null);
final IPentahoSession mockSession = Mockito.mock(IPentahoSession.class);
PentahoSessionHolder.setSession(mockSession);
repository = new FileSystemBackedUnifiedRepository();
repository.deleteFile(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null).getId(), true, null);
assertNotNull(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null));
final MockXmiParser xmiParser = new MockXmiParser();
domainRepository = createDomainRepository(repository, null, xmiParser, null);
domainRepositorySpy = spy(domainRepository);
aclNodeHelper = mock(IAclNodeHelper.class);
doReturn(aclNodeHelper).when(domainRepositorySpy).getAclHelper();
doNothing().when(aclNodeHelper).removeAclFor(any(RepositoryFile.class));
when(aclNodeHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(true);
while (domainRepositorySpy.getDomainIds().size() > 0) {
domainRepositorySpy.removeDomain(domainRepositorySpy.getDomainIds().iterator().next());
}
}
use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.
the class SolutionImportHandlerNamingIT method init.
@Before
public void init() throws IOException, PlatformInitializationException, PlatformImportException, DomainIdNullException, DomainAlreadyExistsException, DomainStorageException {
// repository
File repoDir = new File(tempDir.getAbsolutePath() + REPO_PATH);
FileUtils.forceMkdir(repoDir);
FileUtils.cleanDirectory(repoDir);
repoRoot = repoDir;
repo = new FileSystemBackedUnifiedRepository();
repo = Mockito.spy(repo);
repo.setRootDir(repoRoot);
// mimeResolver
final Converter defaultConverter = new StreamConverter();
final List<IMimeType> solutionMimeList = java.util.Collections.singletonList(MIME_SOLUTION);
final List<IMimeType> contentMimeList = java.util.Arrays.asList(new IMimeType[] { MIME_PRPT, MIME_XML });
final List<IMimeType> allMimeTypes = new ArrayList<IMimeType>(solutionMimeList.size() + contentMimeList.size());
{
allMimeTypes.addAll(solutionMimeList);
allMimeTypes.addAll(contentMimeList);
for (IMimeType mimeType : allMimeTypes) {
mimeType.setConverter(defaultConverter);
}
}
final IPlatformMimeResolver mimeResolver = new NameBaseMimeResolver();
for (IMimeType mimeType : allMimeTypes) {
mimeResolver.addMimeType(mimeType);
}
// platform, import handlers
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));
IRepositoryContentConverterHandler converterHandler = new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>());
RepositoryFileImportFileHandler contentImportFileHandler = new RepositoryFileImportFileHandler(contentMimeList);
contentImportFileHandler.setRepository(repo);
solutionImportHandler = new SolutionImportHandler(solutionMimeList);
List<IPlatformImportHandler> handlers = new ArrayList<IPlatformImportHandler>();
handlers.add(contentImportFileHandler);
handlers.add(solutionImportHandler);
PentahoPlatformImporter importer = new PentahoPlatformImporter(handlers, converterHandler);
importer.setDefaultHandler(contentImportFileHandler);
importer.setRepositoryImportLogger(new Log4JRepositoryImportLogger());
microPlatform.defineInstance(IPlatformImporter.class, importer);
microPlatform.start();
}
use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.
the class MondrianCatalogRepositoryHelperIT method testSchemaFilesContainsAnnotatedSchema.
@Test
public void testSchemaFilesContainsAnnotatedSchema() throws Exception {
FileSystemBackedUnifiedRepository repository = new FileSystemBackedUnifiedRepository(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest");
MondrianCatalogRepositoryHelper helper = new MondrianCatalogRepositoryHelper(repository);
Map<String, InputStream> schemaFiles = helper.getModrianSchemaFiles("food");
assertEquals(3, schemaFiles.size());
assertSchemaFile(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest/etc/mondrian/food/schema.xml", schemaFiles.get("schema.xml"));
assertSchemaFile(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest/etc/mondrian/food/annotations.xml", schemaFiles.get("annotations.xml"));
assertSchemaFile(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest/schema.annotated.xml", schemaFiles.get("schema.annotated.xml"));
}
use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.
the class PentahoSystemPluginManagerIT method init0.
public void init0() {
microPlatform = new MicroPlatform(solutionPath);
microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
microPlatform.define(ISystemConfig.class, SystemConfig.class);
microPlatform.define(IPluginProvider.class, SystemPathXmlPluginProvider.class);
microPlatform.define(IPluginResourceLoader.class, PluginResourceLoader.class);
microPlatform.define(IServiceManager.class, DefaultServiceManager.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/PluginManagerTest"));
session = new StandaloneSession();
pluginManager = new PentahoSystemPluginManager();
}
use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.
the class MetadataQueryComponentIT method setUp.
@Before
public void setUp() throws Exception {
microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
microPlatform.define(IMetadataDomainRepository.class, InMemoryMetadataDomainRepository.class, Scope.GLOBAL);
microPlatform.define("connection-SQL", SQLConnection.class);
microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
FileSystemBackedUnifiedRepository repos = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
repos.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL);
KettleEnvironment.init(false);
IMetadataDomainRepository repo = PentahoSystem.get(IMetadataDomainRepository.class, null);
Domain domain = getBasicDomain();
Domain domain2 = getJdbcDomain();
Domain domain3 = getJdbcDomain();
domain3.setId("JDBCDOMAIN2");
domain3.getLogicalModels().get(0).setProperty("max_rows", new BigDecimal(10));
Domain domain4 = getBasicDomain();
((SqlPhysicalModel) domain4.getPhysicalModels().get(0)).getDatasource().setDialectType("MYSQL");
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("QUOTE_ALL_FIELDS", "Y");
((SqlPhysicalModel) domain4.getPhysicalModels().get(0)).getDatasource().setAttributes(attributes);
domain4.setId("MYSQL_DOMAIN");
repo.storeDomain(domain, true);
repo.storeDomain(domain2, true);
repo.storeDomain(domain3, true);
repo.storeDomain(domain4, true);
// JNDI
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.root", TestResourceLocation.TEST_RESOURCES + "/solution/system/simple-jndi");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.delimiter", "/");
}
Aggregations