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();
}
}
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);
}
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);
}
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"));
}
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);
}
Aggregations