use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class PojoComponentTest method testBadOutput.
public void testBadOutput() {
startTest();
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
try {
String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "test/pojo/pojo-bad5.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("Action sequence 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 IsOutputParameterTest method testIsOutputParameter.
/**
* Assert parameters with is-output-parameter=false don't appear in output
*
* @throws XmlParseException
*/
public void testIsOutputParameter() throws XmlParseException {
startTest();
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "services/" + xactionName);
Document actionSequenceDocument = XmlDom4JHelper.getDocFromString(xactionStr, null);
IActionSequence actionSequence = SequenceDefinition.ActionSequenceFactory(actionSequenceDocument, "", this, // $NON-NLS-1$
PentahoSystem.getApplicationContext(), DEBUG);
Map allParameters = actionSequence.getOutputDefinitions();
Set<String> outParameters = new HashSet<String>();
Set<String> nonOutParameters = new HashSet<String>();
for (Object key : allParameters.keySet()) {
IActionParameter param = (IActionParameter) allParameters.get(key);
if (param.isOutputParameter()) {
outParameters.add(param.getName());
} else {
nonOutParameters.add(param.getName());
}
}
Assert.assertEquals("expected 2 outputable parameters in xaction", 2, outParameters.size());
Assert.assertEquals("expected 1 paramater with is-output-parameter=false", 1, nonOutParameters.size());
IRuntimeContext runtimeContext = // $NON-NLS-1$
solutionEngine.execute(// $NON-NLS-1$
xactionStr, // $NON-NLS-1$
xactionName, // $NON-NLS-1$
"simple output test", // $NON-NLS-1$
false, // $NON-NLS-1$
true, // $NON-NLS-1$
null, // $NON-NLS-1$
false, // $NON-NLS-1$
new HashMap(), null, null, new SimpleUrlFactory(""), // $NON-NLS-1$
new ArrayList());
IParameterManager paramManager = runtimeContext.getParameterManager();
Assert.assertEquals(outParameters.size(), paramManager.getCurrentOutputNames().size());
for (Object key : paramManager.getCurrentOutputNames()) {
Assert.assertTrue("output parameter not found in definition", outParameters.contains(key));
Assert.assertFalse("non-output parameter in output", nonOutParameters.contains(key));
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class ActionDelegateTest method execute.
@SuppressWarnings("unchecked")
private void execute(String actionSequenceFile, boolean exceptionOnError, IAction... actions) throws ActionSequenceException {
TestPluginManager pm = (TestPluginManager) PentahoSystem.get(IPluginManager.class);
for (IAction action : actions) {
pm.addAction(action);
}
// content outputs will write to this stream
out = new ByteArrayOutputStream();
// create SimpleOutputHandler (to handle outputs of type "response.content")
outputHandler = new SimpleOutputHandler(out, false);
outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
IPentahoSession session = new StandaloneSession("system");
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
outputHandler.setSession(session);
String xactionStr = ServiceTestHelper.getXAction("src/test/resources/solution/test/ActionDelegateTest", actionSequenceFile);
// execute the action sequence, providing the outputHandler created above
IRuntimeContext rc = solutionEngine.execute(xactionStr, actionSequenceFile, "action sequence to test the TestAction", false, true, null, false, new HashMap(), outputHandler, null, new SimpleUrlFactory(""), new ArrayList());
int status = rc.getStatus();
if (status == IRuntimeContext.PARAMETERS_FAIL || status == IRuntimeContext.RUNTIME_CONTEXT_RESOLVE_FAIL || status == IRuntimeContext.RUNTIME_STATUS_FAILURE || status == IRuntimeContext.RUNTIME_STATUS_INITIALIZE_FAIL || status == IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL) {
throw new ActionSequenceException("Action sequence failed!");
}
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project data-access by pentaho.
the class DSWDatasourceServiceImpl method listDatasourceNames.
public List<String> listDatasourceNames() throws IOException {
synchronized (CsvDatasourceServiceImpl.lock) {
// $NON-NLS-1$
IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
PMDUIComponent component = new PMDUIComponent(urlFactory, new ArrayList());
component.validate(PentahoSessionHolder.getSession(), null);
component.setAction(PMDUIComponent.ACTION_LIST_MODELS);
Document document = component.getXmlContent();
// $NON-NLS-1$
List<DefaultElement> modelElements = document.selectNodes("//model_name");
ArrayList<String> datasourceNames = new ArrayList<String>();
for (DefaultElement element : modelElements) {
datasourceNames.add(element.getText());
}
return datasourceNames;
}
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class AxisServiceWsdlGeneratorTest method testBadInit3.
@Test
public void testBadInit3() throws Exception {
// $NON-NLS-1$
StandaloneSession session = new StandaloneSession("test");
AxisServiceWsdlGenerator contentGenerator = new AxisServiceWsdlGenerator();
// $NON-NLS-1$
assertNotNull("contentGenerator is null", contentGenerator);
// $NON-NLS-1$
assertNotNull("Logger is null", contentGenerator.getLogger());
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOutputHandler outputHandler = new SimpleOutputHandler(out, false);
// $NON-NLS-1$
String baseUrl = "http://testhost:testport/testcontent";
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
SimpleParameterProvider requestParams = new SimpleParameterProvider();
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParams);
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory(baseUrl + "?");
List<String> messages = new ArrayList<String>();
contentGenerator.setOutputHandler(outputHandler);
MimeTypeListener mimeTypeListener = new MimeTypeListener();
outputHandler.setMimeTypeListener(mimeTypeListener);
contentGenerator.setMessagesList(messages);
contentGenerator.setParameterProviders(parameterProviders);
contentGenerator.setSession(session);
contentGenerator.setUrlFactory(urlFactory);
contentGenerator.createContent();
String content = new String(out.toByteArray());
System.out.println(content);
assertTrue(content.indexOf(Messages.getInstance().getErrorString("WebServiceContentGenerator.ERROR_0001_AXIS_CONFIG_IS_NULL")) != // $NON-NLS-1$
-1);
}
Aggregations