Search in sources :

Example 16 with StandaloneApplicationContext

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

the class BaseTestCase method init.

protected void init(String solnPath) {
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    // $NON-NLS-1$
    applicationContext = new StandaloneApplicationContext(solnPath, "");
    applicationContext.setFullyQualifiedServerURL(getFullyQualifiedServerURL());
    // $NON-NLS-1$ //$NON-NLS-2$
    String inContainer = System.getProperty("incontainer", "false");
    if (inContainer.equalsIgnoreCase("false")) {
        // $NON-NLS-1$
        // Setup simple-jndi for datasources
        // $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", getSolutionPath() + "/system/simple-jndi");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.delimiter", "/");
    }
    // $NON-NLS-1$
    String objectFactoryCreatorCfgFile = getSolutionPath() + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME;
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(objectFactoryCreatorCfgFile, null);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    PentahoSystem.init(applicationContext);
    // $NON-NLS-1$
    session = new StandaloneSession("system");
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 17 with StandaloneApplicationContext

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

the class GenericPentahoTest method getSolutionEngine.

public ISolutionEngine getSolutionEngine(String path) {
    // $NON-NLS-1$
    StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(path, "");
    if (!PentahoSystem.getInitializedOK()) {
        PentahoSystem.init(applicationContext);
        // $NON-NLS-1$
        assertTrue("PentahoSystem did not initialize", PentahoSystem.getInitializedOK());
    }
    // $NON-NLS-1$
    IPentahoSession session = new StandaloneSession("system");
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    // $NON-NLS-1$
    assertNotNull("SolutionEngine is null", solutionEngine);
    solutionEngine.setLoggingLevel(ILogger.ERROR);
    solutionEngine.init(session);
    try {
        solutionEngine.setSession(session);
        return solutionEngine;
    } catch (Exception e) {
        // we should not get here
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
    }
    return null;
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 18 with StandaloneApplicationContext

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

the class SystemSettingsTest method init.

public boolean init() {
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    File file = new File(SOLUTION_PATH + PENTAHO_XML_PATH);
    StandaloneApplicationContext applicationContext = null;
    if (file.exists()) {
        // $NON-NLS-1$
        applicationContext = new StandaloneApplicationContext(SystemSettingsTest.SOLUTION_PATH, "");
    } else {
        // $NON-NLS-1$
        applicationContext = new StandaloneApplicationContext(SystemSettingsTest.ALT_SOLUTION_PATH, "");
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    String inContainer = System.getProperty("incontainer", "false");
    if (inContainer.equalsIgnoreCase("false")) {
        // $NON-NLS-1$
        // Setup simple-jndi for datasources
        // $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", getSolutionPath() + "/system/simple-jndi");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.delimiter", "/");
    }
    // $NON-NLS-1$
    String objectFactoryCreatorCfgFile = getSolutionPath() + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME;
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(objectFactoryCreatorCfgFile, null);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    return PentahoSystem.init(applicationContext);
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) File(java.io.File) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 19 with StandaloneApplicationContext

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

the class MessageFormatterTest method before.

@Before
public void before() {
    mockedRuntimeRepository = mock(IRuntimeRepository.class);
    mockedSolutionEngine = mock(ISolutionEngine.class);
    mockedPentahoSystem = new MockUp<PentahoSystem>() {

        @Mock
        public IApplicationContext getApplicationContext() {
            final String solutionPath = ".";
            final String applicationPath = "";
            return new StandaloneApplicationContext(solutionPath, applicationPath);
        }
    };
    runtimeCtx = spy(new RuntimeContext("id", mockedSolutionEngine, "solutionName", makeRuntimeData(session), session, null, "processId", urlFactory, makeParameterProviders(session), new ArrayList<String>(), null));
}
Also used : IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) RuntimeContext(org.pentaho.platform.engine.services.runtime.RuntimeContext) PentahoSystem(org.pentaho.platform.engine.core.system.PentahoSystem) Mock(mockit.Mock) Before(org.junit.Before)

Example 20 with StandaloneApplicationContext

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

the class PluginManagerNotConfiguredIT method setUp.

public void setUp() {
    List<?> messages = TestManager.getMessagesList();
    if (messages == null) {
        messages = new ArrayList<String>();
    }
    if (initOk) {
        return;
    }
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    if (PentahoSystem.getApplicationContext() == null) {
        // $NON-NLS-1$
        StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
        // $NON-NLS-1$ //$NON-NLS-2$
        String inContainer = System.getProperty("incontainer", "false");
        if (inContainer.equalsIgnoreCase("false")) {
            // $NON-NLS-1$
            // Setup simple-jndi for datasources
            // $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", getSolutionPath() + "/system/simple-jndi");
            // $NON-NLS-1$ //$NON-NLS-2$
            System.setProperty("org.osjava.sj.delimiter", "/");
        }
        ApplicationContext springApplicationContext = getSpringApplicationContext();
        IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
        pentahoObjectFactory.init(null, springApplicationContext);
        PentahoSystem.registerObjectFactory(pentahoObjectFactory);
        // force Spring to populate PentahoSystem
        // $NON-NLS-1$
        springApplicationContext.getBean("pentahoSystemProxy");
        initOk = PentahoSystem.init(applicationContext);
    } else {
        initOk = true;
    }
    initOk = true;
}
Also used : StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Aggregations

StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)23 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)8 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)7 PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)7 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)5 File (java.io.File)4 ApplicationContext (org.springframework.context.ApplicationContext)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)4 Properties (java.util.Properties)3 Before (org.junit.Before)3 Test (org.junit.Test)3 IApplicationContext (org.pentaho.platform.api.engine.IApplicationContext)3 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)3 ArrayList (java.util.ArrayList)2 Mock (mockit.Mock)2 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)2 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)2 IRuntimeRepository (org.pentaho.platform.api.repository.IRuntimeRepository)2 PentahoSystem (org.pentaho.platform.engine.core.system.PentahoSystem)2 FileInputStream (java.io.FileInputStream)1