Search in sources :

Example 41 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class JcrStringHelperTest method testFilePathSpecEncodeDecodeUsingMultiByteEncoding.

@Test
public void testFilePathSpecEncodeDecodeUsingMultiByteEncoding() throws PlatformInitializationException {
    MicroPlatform mp = new MicroPlatform(getSolutionPath());
    mp.defineInstance("useMultiByteEncoding", new Boolean(true));
    // Start the micro-platform
    mp.start();
    JcrStringHelper.setMultiByteEncodingEnabled(true);
    String path = "/asdf/3err";
    String encodedPath = JcrStringHelper.pathEncode(path);
    assertFalse(path.equals(encodedPath));
    String decodedPath = JcrStringHelper.fileNameDecode(encodedPath);
    assertEquals(path, decodedPath);
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Test(org.junit.Test)

Example 42 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class JcrStringHelperTest method testFilePath_1Encode.

@Test
public void testFilePath_1Encode() throws PlatformInitializationException {
    MicroPlatform mp = new MicroPlatform(getSolutionPath());
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    // Start the micro-platform
    mp.start();
    JcrStringHelper.setMultiByteEncodingEnabled(false);
    String path = "/asdf/3err";
    String encodedPath = JcrStringHelper.pathEncode(path);
    assertEquals(path, encodedPath);
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Test(org.junit.Test)

Example 43 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class JcrStringHelperTest method testFilePathSpecEncodeDecode.

@Test
public void testFilePathSpecEncodeDecode() throws PlatformInitializationException {
    MicroPlatform mp = new MicroPlatform(getSolutionPath());
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    // Start the micro-platform
    mp.start();
    JcrStringHelper.setMultiByteEncodingEnabled(false);
    String path = "/asdf/3err";
    String encodedPath = JcrStringHelper.pathEncode(path);
    assertEquals(path, encodedPath);
    String decodedPath = JcrStringHelper.fileNameDecode(encodedPath);
    assertEquals(path, decodedPath);
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Test(org.junit.Test)

Example 44 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class EmbeddedVersionCheckSystemListenerIT method init.

@Before
public void init() throws SchedulerException, PlatformInitializationException {
    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();
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) Before(org.junit.Before)

Example 45 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform 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();
}
Also used : ArrayList(java.util.ArrayList) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) SolutionEngine(org.pentaho.platform.engine.services.solution.SolutionEngine) IDatasourceMgmtService(org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) IRepositoryContentConverterHandler(org.pentaho.platform.api.repository2.unified.IRepositoryContentConverterHandler) IPlatformMimeResolver(org.pentaho.platform.api.mimetype.IPlatformMimeResolver) Log4JRepositoryImportLogger(org.pentaho.platform.plugin.services.importexport.Log4JRepositoryImportLogger) StreamConverter(org.pentaho.platform.plugin.services.importexport.StreamConverter) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Converter(org.pentaho.platform.api.repository2.unified.Converter) StreamConverter(org.pentaho.platform.plugin.services.importexport.StreamConverter) File(java.io.File) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Aggregations

MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)64 Before (org.junit.Before)40 File (java.io.File)15 Test (org.junit.Test)12 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)10 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)10 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)10 RepositoryFileProxyFactory (org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)9 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)8 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)8 BeforeClass (org.junit.BeforeClass)7 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)6 ArrayList (java.util.ArrayList)5 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)5 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)5 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)5 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ITenant (org.pentaho.platform.api.mt.ITenant)4