use of org.pentaho.platform.engine.core.system.StandaloneApplicationContext 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);
}
use of org.pentaho.platform.engine.core.system.StandaloneApplicationContext in project pentaho-kettle by pentaho.
the class RepositoryFactoryTest method setup.
@BeforeClass
public static void setup() throws Exception {
PentahoSystem.init(new StandaloneApplicationContext("", ""));
KettleEnvironment.init();
}
use of org.pentaho.platform.engine.core.system.StandaloneApplicationContext in project pentaho-platform by pentaho.
the class KarafBootTest method testClearDataCacheSetting.
@Test
public void testClearDataCacheSetting() throws Exception {
// clear Karaf's property to avoid tests' interdependency
System.clearProperty("karaf.data");
PentahoSystem.init(new StandaloneApplicationContext(TestResourceLocation.TEST_RESOURCES + "/karafBootTest", "."));
// set property
KarafBoot karafBoot = new KarafBoot();
File root = Files.createTempDirectory(Paths.get("."), "root").toFile();
File caches = new File(root, "caches");
caches.mkdir();
for (int i = 0; i < 5; i++) {
File clientTypeFolder = new File(caches, "client" + i);
clientTypeFolder.mkdir();
for (int y = 0; y < 3; y++) {
new File(clientTypeFolder, "data-" + y).mkdir();
}
}
FileUtils.copyDirectory(new File(TestResourceLocation.TEST_RESOURCES + "/karafBootTest/system/karaf/etc"), new File(root, "etc"));
FileOutputStream fileOutputStream = null;
FileInputStream fileInputStream = null;
try {
Properties config = new Properties();
File configFile = new File(root + "/etc/custom.properties");
fileInputStream = new FileInputStream(configFile);
config.load(fileInputStream);
fileInputStream.close();
config.setProperty("org.pentaho.clean.karaf.cache", "true");
fileOutputStream = new FileOutputStream(configFile);
config.store(fileOutputStream, "setting stage");
karafBoot.cleanCachesIfFlagSet(root.getPath());
// Check that all data directories are gone
for (int i = 0; i < 5; i++) {
File clientTypeFolder = new File(caches, "client" + i);
File[] files = clientTypeFolder.listFiles();
assertEquals(0, files.length);
}
fileInputStream = new FileInputStream(configFile);
config.load(fileInputStream);
assertEquals("false", config.getProperty("org.pentaho.clean.karaf.cache"));
} finally {
if (fileOutputStream != null) {
fileOutputStream.close();
}
if (fileInputStream != null) {
fileInputStream.close();
}
}
if (root.exists()) {
FileUtils.deleteDirectory(root);
}
}
use of org.pentaho.platform.engine.core.system.StandaloneApplicationContext in project pentaho-platform by pentaho.
the class SystemResourceIT method setUp.
@Before
public void setUp() throws Exception {
mp = new MicroPlatform();
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.start();
ISystemConfig systemConfig = new SystemConfig();
IConfiguration securityConfig = mock(IConfiguration.class);
Properties props = new Properties();
props.setProperty("provider", "jackrabbit");
when(securityConfig.getProperties()).thenReturn(props);
when(securityConfig.getId()).thenReturn("security");
systemConfig.registerConfiguration(securityConfig);
systemResource = new SystemResource(systemConfig);
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
ApplicationContext springApplicationContext = getSpringApplicationContext();
IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
pentahoObjectFactory.init(null, springApplicationContext);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
// force Spring to populate PentahoSystem
boolean initOk = PentahoSystem.init(applicationContext);
/*
* StandaloneSession session = new StandaloneSession();
*
* StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory( );
*
* File f = new File(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml"); FileSystemResource fsr = new
* FileSystemResource(f); GenericApplicationContext appCtx = new GenericApplicationContext();
* XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); xmlReader.loadBeanDefinitions(fsr);
*
* factory.init(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml", appCtx );
*/
}
use of org.pentaho.platform.engine.core.system.StandaloneApplicationContext in project pentaho-platform by pentaho.
the class ContentOutputComponentIT method setUp.
public void setUp() {
super.setUp();
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
PentahoSystem.init(applicationContext, getRequiredListeners());
}
Aggregations