Search in sources :

Example 1 with PathBasedSystemSettings

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

the class IntegrationTestUtil method initializePentahoSystem.

public static synchronized void initializePentahoSystem(String solutionPath) throws Exception {
    // this setting is useful only for running the integration tests from within IntelliJ
    // this same property is set for integration tests via the pom when running with mvn
    String folderPaths = "target/spoon/plugins";
    File f = new File(folderPaths);
    System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", f.getAbsolutePath());
    StandaloneApplicationContext appContext = new StandaloneApplicationContext(solutionPath, "");
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    if (solutionPath == null) {
        throw new MetaverseException(Messages.getString("ERROR.MetaverseInit.BadConfigPath", solutionPath));
    }
    try {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(MetaverseUtil.class.getClassLoader());
        IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
        pentahoObjectFactory.init(solutionPath, PentahoSystem.getApplicationContext());
        PentahoSystem.registerObjectFactory(pentahoObjectFactory);
        // Restore context classloader
        Thread.currentThread().setContextClassLoader(cl);
    } catch (Exception e) {
        throw new MetaverseException(Messages.getString("ERROR.MetaverseInit.CouldNotInit"), e);
    }
    PentahoSystem.init(appContext);
    PentahoSessionHolder.setSession(new StandaloneSession());
    registerKettlePlugins();
    try {
        KettleEnvironment.init();
    } catch (KettleException e) {
        e.printStackTrace();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) MetaverseUtil(org.pentaho.metaverse.util.MetaverseUtil) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) File(java.io.File) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) MetaverseException(org.pentaho.metaverse.api.MetaverseException) KettleException(org.pentaho.di.core.exception.KettleException) MetaverseException(org.pentaho.metaverse.api.MetaverseException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 2 with PathBasedSystemSettings

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

the class LocalizationServletIT method init.

@BeforeClass
public static void init() throws PlatformInitializationException {
    StandaloneSession session = new StandaloneSession();
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/web-servlet-solution");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IServiceManager.class, DefaultServiceManager.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    microPlatform.define(IPluginResourceLoader.class, PluginResourceLoader.class);
    microPlatform.define(IPluginProvider.class, SystemPathXmlPluginProvider.class);
    microPlatform.define(IPluginManager.class, DefaultPluginManager.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    PentahoSessionHolder.setSession(session);
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class);
    microPlatform.define(IPluginProvider.class, TestPluginProvider.class);
    microPlatform.start();
    pluginManager.reload(session);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) BeforeClass(org.junit.BeforeClass)

Example 3 with PathBasedSystemSettings

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

the class MultipleComponentIT method testPathBasedSystemSettings.

/*
   * public void testUIUtil() { List messages = new ArrayList(); messages.add("Error Message One"); //$NON-NLS-1$
   * messages.add("Error Message Two"); //$NON-NLS-1$
   * messages.add("Error: This is the first error Error: message - MultipleComponentTest"); //$NON-NLS-1$ StringBuffer
   * messageBuffer = new StringBuffer(); UIUtil.formatErrorMessage("text/html", "Error Test", messages, messageBuffer);
   * //$NON-NLS-1$ //$NON-NLS-2$ String result = messageBuffer.toString();
   * assertTrue(result.indexOf("Error Message Two")>=0); //$NON-NLS-1$ String msg = UIUtil.getFirstError(messages);
   * assertTrue(msg.indexOf("MultipleComponentTest")>=0); //$NON-NLS-1$ IPentahoResultSet rs = getResultSet();
   * StringBuffer formattedRs = new StringBuffer(); UIUtil.formatResultSetAsHTMLRows(rs, formattedRs);
   * System.out.println(formattedRs.toString()); assertTrue(formattedRs.indexOf("<th>COL3</th>")>=0); //$NON-NLS-1$ }
   */
public void testPathBasedSystemSettings() {
    PathBasedSystemSettings settings = new PathBasedSystemSettings();
    // $NON-NLS-1$
    String cfgPathKey = settings.getSystemSetting(PathBasedSystemSettings.SYSTEM_CFG_PATH_KEY, "");
    List list = settings.getSystemSettings(PathBasedSystemSettings.SYSTEM_CFG_PATH_KEY);
    for (int i = 0; i < list.size(); i++) {
        // $NON-NLS-1$
        System.out.println("System Settings" + (i + 1) + list.get(i));
    }
    // $NON-NLS-1$
    System.setProperty(PathBasedSystemSettings.SYSTEM_CFG_PATH_KEY, "");
    // $NON-NLS-1$
    settings.getSystemSetting("c:/code", PathBasedSystemSettings.SYSTEM_CFG_PATH_KEY, null);
    System.setProperty(PathBasedSystemSettings.SYSTEM_CFG_PATH_KEY, cfgPathKey);
    assertTrue(true);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings)

Example 4 with PathBasedSystemSettings

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

the class SystemConfigIT method testSystemSettingsConfiguration.

@Test
public void testSystemSettingsConfiguration() throws Exception {
    PentahoSystem.clearObjectFactory();
    PentahoSystem.setApplicationContext(new StandaloneApplicationContext(TestResourceLocation.TEST_RESOURCES + "/SystemConfig", ""));
    SystemSettingsConfiguration settings = new SystemSettingsConfiguration("system", new PathBasedSystemSettings());
    Properties props = settings.getProperties();
    assertNotNull(props);
    assertEquals("Hypersonic", props.get("sampledata-datasource.type"));
}
Also used : StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) Properties(java.util.Properties) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) Test(org.junit.Test)

Example 5 with PathBasedSystemSettings

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

the class BaseTest method setUp.

@Override
public void setUp() {
    // used by test repository impl such as FileSystemRepositoryFileDao
    System.setProperty("solution.root.dir", getSolutionPath());
    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(), "");
        // set the base url assuming there is a running server on port 8080
        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", "/");
        }
        ApplicationContext springApplicationContext = getSpringApplicationContext();
        IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
        pentahoObjectFactory.init(null, springApplicationContext);
        PentahoSystem.registerObjectFactory(pentahoObjectFactory);
        // force Spring to inject PentahoSystem, there has got to be a better way than this, perhaps an alternate way
        // of
        // initting spring's app context
        // $NON-NLS-1$
        springApplicationContext.getBean("pentahoSystemProxy");
        // Initialize SecurityHelper with a mock for testing
        SecurityHelper.setMockInstance(new MockSecurityHelper());
        initOk = PentahoSystem.init(applicationContext);
    } else {
        initOk = true;
    }
    // $NON-NLS-1$
    assertTrue(Messages.getInstance().getString("BaseTest.ERROR_0001_FAILED_INITIALIZATION"), initOk);
}
Also used : MockSecurityHelper(org.pentaho.test.platform.engine.security.MockSecurityHelper) 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

PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)13 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)7 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)7 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)6 File (java.io.File)5 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)5 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)4 ApplicationContext (org.springframework.context.ApplicationContext)3 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)2 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 Test (org.junit.Test)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1 MetaverseUtil (org.pentaho.metaverse.util.MetaverseUtil)1