use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.
the class BootTest method testBootActions.
@Test
public void testBootActions() throws Exception {
PentahoSystemBoot boot = new PentahoSystemBoot();
boot.setFilePath("src/test/resources/solution");
boot.define(ISolutionEngine.class.getSimpleName(), Object1.class.getName(), IPentahoDefinableObjectFactory.Scope.GLOBAL);
TestStartupAction startupAction1 = new TestStartupAction();
TestStartupAction startupAction2 = new TestStartupAction();
boot.addStartupAction(startupAction1);
List<ISessionStartupAction> startupActions1 = boot.getStartupActions();
assertEquals(1, startupActions1.size());
assertEquals(startupAction1, startupActions1.get(0));
List<ISessionStartupAction> startupActions2 = new ArrayList<ISessionStartupAction>();
startupActions2.add(startupAction2);
boot.setStartupActions(startupActions2);
List<ISessionStartupAction> startupActions3 = boot.getStartupActions();
assertEquals(1, startupActions3.size());
assertEquals(startupAction2, startupActions3.get(0));
assertEquals(startupActions2, startupActions3);
IPentahoObjectFactory factory = boot.getFactory();
assertNotNull("object factory is null", factory);
assertTrue("object factory not definable", factory instanceof IPentahoDefinableObjectFactory);
assertFalse(boot.isInitialized());
boolean ok = boot.start();
assertNull(boot.getSettingsProvider());
assertTrue(boot.isInitialized());
assertTrue(ok);
boot.stop();
assertFalse(boot.isInitialized());
}
use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.
the class PentahoSystemTest method initXMLFactories.
private void initXMLFactories(boolean factoriesInPentahoXML) throws Exception {
// mock pentaho.xml
final ISystemSettings settingsService = mock(ISystemSettings.class);
if (factoriesInPentahoXML) {
final Node testNode = mock(Node.class);
final Node testNodeName = mock(Node.class);
when(testNodeName.getText()).thenReturn(testSystemPropertyName);
when(testNode.selectSingleNode(eq("@name"))).thenReturn(testNodeName);
final Node testNodeImplementation = mock(Node.class);
when(testNodeImplementation.getText()).thenReturn(testXMLValue);
when(testNode.selectSingleNode(eq("@implementation"))).thenReturn(testNodeImplementation);
when(settingsService.getSystemSettings("xml-factories/factory-impl")).thenReturn(new LinkedList<Node>() {
{
add(testNode);
}
});
} else {
when(settingsService.getSystemSettings("xml-factories/factory-impl")).thenReturn(new LinkedList<Node>());
}
when(settingsService.getSystemSetting(anyString(), anyString())).thenReturn("");
PentahoSystem.setSystemSettingsService(settingsService);
// mock java-system-properties.properties
final IPentahoObjectFactory objectFactory = mock(IPentahoObjectFactory.class);
final ISystemConfig systemConfig = mock(ISystemConfig.class);
final IConfiguration configuration = mock(IConfiguration.class);
when(configuration.getProperties()).thenReturn(new Properties() {
{
setProperty(testSystemPropertyName, testPropertyValue);
}
});
when(systemConfig.getConfiguration(eq(PentahoSystem.JAVA_SYSTEM_PROPERTIES))).thenReturn(configuration);
when(objectFactory.objectDefined(eq(ISystemConfig.class))).thenReturn(true);
final IPentahoObjectReference pentahoObjectReference = mock(IPentahoObjectReference.class);
when(pentahoObjectReference.getObject()).thenReturn(systemConfig);
when(objectFactory.getObjectReferences(eq(ISystemConfig.class), any(IPentahoSession.class), nullable(Map.class))).thenReturn(new LinkedList() {
{
add(pentahoObjectReference);
}
});
PentahoSystem.registerObjectFactory(objectFactory);
PentahoSystem.init();
}
Aggregations