use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class ServiceLayerTest method testEmptyActionSequence.
@Test
public void testEmptyActionSequence() throws IOException {
List<Object> messages = new ArrayList<Object>();
String instanceId = null;
IPentahoSession session = new StandaloneSession("system");
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
solutionEngine.setLoggingLevel(ILogger.ERROR);
solutionEngine.init(session);
Map<Object, Object> parameterProviderMap = new HashMap<Object, Object>();
IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
Reader reader = null;
try {
File file = new File(SOLUTION_PATH + "/services_layer/test1.xaction");
StringBuilder str = new StringBuilder();
reader = new FileReader(file);
char[] buffer = new char[4096];
int n = reader.read(buffer);
while (n != -1) {
str.append(buffer, 0, n);
n = reader.read(buffer);
}
String xactionStr = str.toString();
solutionEngine.setSession(session);
IRuntimeContext runtimeContext = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
xactionStr, // $NON-NLS-1$ //$NON-NLS-2$
"test1.xaction", // $NON-NLS-1$ //$NON-NLS-2$
"empty action sequence test", // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, // $NON-NLS-1$ //$NON-NLS-2$
instanceId, false, parameterProviderMap, null, null, urlFactory, messages);
assertNotNull("RuntimeContext is null", runtimeContext);
assertEquals("Action sequence execution failed", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_SUCCESS);
} catch (Exception e) {
// we should not get here
e.printStackTrace();
assertTrue(e.getMessage(), false);
} finally {
if (reader != null) {
reader.close();
}
}
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class PojoComponentTest method testBadValidate.
public void testBadValidate() {
startTest();
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
try {
String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "test/pojo/pojo-bad3.xaction");
PojoComponentTest.doneCalled = false;
PojoComponentTest.executeCalled = false;
PojoComponentTest.validateCalled = false;
IRuntimeContext runtimeContext = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
xactionStr, // $NON-NLS-1$ //$NON-NLS-2$
"test", // $NON-NLS-1$ //$NON-NLS-2$
"invalid class setting test", // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, // $NON-NLS-1$ //$NON-NLS-2$
null, // $NON-NLS-1$ //$NON-NLS-2$
false, new HashMap(), null, null, new SimpleUrlFactory(""), new ArrayList());
assertNotNull("RuntimeContext is null", runtimeContext);
assertEquals("execute was called", false, PojoComponentTest.executeCalled);
assertEquals("validate was not called", true, PojoComponentTest.validateCalled);
assertEquals("Action sequence execution succeeded", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_FAILURE);
} catch (Exception e) {
// we should not get here
e.printStackTrace();
assertTrue(e.getMessage(), false);
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class PojoComponentTest method testSimplePojoSettings.
public void testSimplePojoSettings() {
startTest();
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
try {
String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "test/pojo/pojo1b.xaction");
PojoComponentTest.doneCalled = false;
IRuntimeContext runtimeContext = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
xactionStr, // $NON-NLS-1$ //$NON-NLS-2$
"pojo1b.xaction", // $NON-NLS-1$ //$NON-NLS-2$
"empty action sequence test", // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, // $NON-NLS-1$ //$NON-NLS-2$
null, // $NON-NLS-1$ //$NON-NLS-2$
false, new HashMap(), null, null, new SimpleUrlFactory(""), new ArrayList());
IActionParameter param = runtimeContext.getOutputParameter("output1");
assertNotNull("RuntimeContext is null", runtimeContext);
assertTrue("done() was not called", PojoComponentTest.doneCalled);
assertEquals("setInt1 failed", 11, TestPojo1.int1);
assertEquals("setInt2 failed", new Integer(22), TestPojo1.int2);
assertEquals("setBoolean1 failed", true, TestPojo1.bool1);
assertEquals("setBoolean2 failed", new Boolean(true), TestPojo1.bool2);
assertEquals("setLong1 failed", 88, TestPojo1.long1);
assertEquals("setLong2 failed", new Long(99), TestPojo1.long2);
assertEquals("setBigDecimal failed", new BigDecimal("77.7"), TestPojo1.bigDecimal);
assertEquals("setFloat1 failed", "33.3", Float.toString(TestPojo1.float1));
assertEquals("setFloat2 failed", "44.4", TestPojo1.float2.toString());
assertEquals("setDouble1 failed", "55.5", Double.toString(TestPojo1.double1));
assertEquals("setDouble2 failed", "66.6", TestPojo1.double2.toString());
assertEquals("Action sequence execution failed", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_SUCCESS);
} catch (Exception e) {
// we should not get here
e.printStackTrace();
assertTrue(e.getMessage(), false);
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class PojoComponentTest method testBadClassSetting.
public void testBadClassSetting() {
startTest();
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
try {
String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "test/pojo/pojo-bad2.xaction");
PojoComponentTest.doneCalled = false;
PojoComponentTest.executeCalled = false;
PojoComponentTest.validateCalled = false;
IRuntimeContext runtimeContext = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
xactionStr, // $NON-NLS-1$ //$NON-NLS-2$
"test", // $NON-NLS-1$ //$NON-NLS-2$
"invalid class setting test", // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, // $NON-NLS-1$ //$NON-NLS-2$
null, // $NON-NLS-1$ //$NON-NLS-2$
false, new HashMap(), null, null, new SimpleUrlFactory(""), new ArrayList());
assertNotNull("RuntimeContext is null", runtimeContext);
assertEquals("execute was called", false, PojoComponentTest.executeCalled);
assertEquals("validate was called", false, PojoComponentTest.validateCalled);
assertEquals("Action sequence validation succeeded", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL);
} catch (Exception e) {
// we should not get here
e.printStackTrace();
assertTrue(e.getMessage(), false);
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class PojoComponentTest method testRuntimeInputsAndOutputs.
public void testRuntimeInputsAndOutputs() {
startTest();
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
try {
String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "test/pojo/pojo5.xaction");
IRuntimeContext runtimeContext = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
xactionStr, // $NON-NLS-1$ //$NON-NLS-2$
"pojo5.xaction", // $NON-NLS-1$ //$NON-NLS-2$
"empty action sequence test", // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, // $NON-NLS-1$ //$NON-NLS-2$
null, // $NON-NLS-1$ //$NON-NLS-2$
false, new HashMap(), null, null, new SimpleUrlFactory(""), new ArrayList());
assertNotNull("RuntimeContext is null", runtimeContext);
assertEquals("Action sequence execution failed", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_SUCCESS);
IActionParameter param = runtimeContext.getOutputParameter("output1");
assertNotNull("param is null", param);
assertEquals("hello", param.getValue().toString());
param = runtimeContext.getOutputParameter("output2");
assertNotNull("param is null", param);
assertEquals("world", param.getValue().toString());
} catch (Exception e) {
// we should not get here
e.printStackTrace();
assertTrue(e.getMessage(), false);
}
finishTest();
}
Aggregations