Search in sources :

Example 96 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class BaseTest method run.

public IRuntimeContext run(String actionPath, IParameterProvider parameterProvider, String testName, String fileExtension) {
    assertTrue(initOk);
    OutputStream outputStream = null;
    if (testName != null && fileExtension != null) {
        outputStream = getOutputStream(testName, fileExtension);
    }
    IOutputHandler outputHandler = null;
    if (outputStream != null) {
        outputHandler = getOutputHandler(outputStream);
    } else {
        outputHandler = getOutputHandler((OutputStream) null);
    }
    String instanceId = null;
    StandaloneSession initialSession = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    IPentahoSession session = sessionStartup(initialSession);
    if (outputHandler != null) {
        outputHandler.setSession(session);
    }
    return run(actionPath, instanceId, false, parameterProvider, outputHandler, session);
}
Also used : IOutputHandler(org.pentaho.platform.api.engine.IOutputHandler) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) OutputStream(java.io.OutputStream)

Example 97 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class SolutionPublisherTest method testSolutionPublishI18N.

public void testSolutionPublishI18N() {
    startTest();
    Locale tmpLocale = LocaleHelper.getLocale();
    // Try a different locale from the default
    // $NON-NLS-1$
    String localeLanguage = "fr";
    // $NON-NLS-1$
    String localeCountry = "FR";
    Locale[] locales = Locale.getAvailableLocales();
    if (locales != null) {
        for (int i = 0; i < locales.length; i++) {
            if (locales[i].getLanguage().equals(localeLanguage) && locales[i].getCountry().equals(localeCountry)) {
                LocaleHelper.setLocale(locales[i]);
                break;
            }
        }
    }
    SolutionPublisher publisher = new SolutionPublisher();
    publisher.setLoggingLevel(getLoggingLevel());
    StandaloneSession session = new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    String result = publisher.publish(session, getLoggingLevel());
    assertEquals(Messages.getInstance().getString("SolutionPublisher.USER_SOLUTION_REPOSITORY_UPDATED"), result);
    // now set the locale back again
    LocaleHelper.setLocale(tmpLocale);
    finishTest();
}
Also used : Locale(java.util.Locale) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession)

Example 98 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pdi-platform-plugin by pentaho.

the class PdiActionTest method init.

@Before
public void init() throws SchedulerException, PlatformInitializationException {
    // $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", SOLUTION_REPOSITORY);
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("org.osjava.sj.delimiter", "/");
    // $NON-NLS-2$
    System.setProperty("PENTAHO_SYS_CFG_PATH", new File(SOLUTION_REPOSITORY + "/pentaho.xml").getAbsolutePath());
    IPentahoSession session = new StandaloneSession();
    PentahoSessionHolder.setSession(session);
    scheduler = new QuartzScheduler();
    scheduler.start();
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    mp.define(UserDetailsService.class, StubUserDetailService.class);
    mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
    mp.setSettingsProvider(new PathBasedSystemSettings());
    mp.defineInstance(IScheduler.class, scheduler);
    mp.define(ISolutionEngine.class, SolutionEngine.class);
    FileSystemBackedUnifiedRepository repo = new FileSystemBackedUnifiedRepository(SOLUTION_REPOSITORY);
    mp.defineInstance(IUnifiedRepository.class, repo);
    mp.start();
    SecurityHelper.getInstance().becomeUser(TEST_USER);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) QuartzScheduler(org.pentaho.platform.scheduler2.quartz.QuartzScheduler) File(java.io.File) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Example 99 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pdi-platform-plugin by pentaho.

the class PdiContentGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    // $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", SOLUTION_REPOSITORY);
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("org.osjava.sj.delimiter", "/");
    // $NON-NLS-2$
    System.setProperty("PENTAHO_SYS_CFG_PATH", new File(SOLUTION_REPOSITORY + "/pentaho.xml").getAbsolutePath());
    IPentahoSession session = new StandaloneSession();
    PentahoSessionHolder.setSession(session);
    pdiContentGenerator = new PdiContentGenerator();
    pdiAction = new PdiAction();
    pdiAction.setRepositoryName(KettleFileRepositoryMeta.REPOSITORY_TYPE_ID);
    pdiContentGenerator.setPdiAction(pdiAction);
    outputStream = mock(OutputStream.class);
    repositoryFile = mock(RepositoryFile.class);
    pdiContentGenerator.setOutputStream(outputStream);
    pdiContentGenerator.setRepositoryFile(repositoryFile);
    scheduler = new QuartzScheduler();
    scheduler.start();
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    mp.define(UserDetailsService.class, StubUserDetailService.class);
    mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
    mp.defineInstance(IScheduler.class, scheduler);
    mp.define(ISolutionEngine.class, SolutionEngine.class);
    FileSystemBackedUnifiedRepository repo = new FileSystemBackedUnifiedRepository(SOLUTION_REPOSITORY);
    mp.defineInstance(IUnifiedRepository.class, repo);
    mp.start();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) OutputStream(java.io.OutputStream) QuartzScheduler(org.pentaho.platform.scheduler2.quartz.QuartzScheduler) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Example 100 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pdi-platform-plugin by pentaho.

the class UserParametersTest method init.

@Before
public void init() throws PlatformInitializationException {
    System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
    System.setProperty("org.osjava.sj.root", "test-src/simple-jndi");
    System.setProperty("org.osjava.sj.delimiter", "/");
    System.setProperty("PENTAHO_SYS_CFG_PATH", new File(SOLUTION_REPOSITORY + "/pentaho.xml").getAbsolutePath());
    IPentahoSession session = new StandaloneSession();
    PentahoSessionHolder.setSession(session);
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    mp.define(UserDetailsService.class, StubUserDetailService.class);
    mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
    mp.setSettingsProvider(new PathBasedSystemSettings());
    mp.define(ISolutionEngine.class, SolutionEngine.class);
    FileSystemBackedUnifiedRepository repo = new FileSystemBackedUnifiedRepository(SOLUTION_REPOSITORY);
    mp.defineInstance(IUnifiedRepository.class, repo);
    mp.start();
    SecurityHelper.getInstance().becomeUser(TEST_USER);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) File(java.io.File) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Aggregations

StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)218 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)74 ArrayList (java.util.ArrayList)46 Authentication (org.springframework.security.core.Authentication)39 Test (org.junit.Test)38 OutputStream (java.io.OutputStream)34 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)30 GrantedAuthority (org.springframework.security.core.GrantedAuthority)30 User (org.springframework.security.core.userdetails.User)30 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)29 UserDetails (org.springframework.security.core.userdetails.UserDetails)29 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)24 File (java.io.File)21 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)21 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)21 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)20 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)20 HashMap (java.util.HashMap)16 Before (org.junit.Before)16