use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class HTMLComponentIT method testComponent1.
public void testComponent1() {
startTest();
// This should succeed
// $NON-NLS-1$
String url = "http://www.pentaho.org/demo/news.html";
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
ArrayList messages = new ArrayList();
// $NON-NLS-1$
HtmlComponent component = new HtmlComponent(HtmlComponent.TYPE_URL, url, "", urlFactory, messages);
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
try {
// $NON-NLS-1$//$NON-NLS-2$
OutputStream outputStream = getOutputStream("HTMLComponentTest.testComponent1", ".html");
component.validate(session, null);
// $NON-NLS-1$
String content = component.getContent("text/html");
outputStream.write(content.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class ReportingIT method testActionComponent.
/*
* public void testBIRTReport1() { startTest(); SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream
* outputStream = getOutputStream("ReportingTest.testBIRTReport1-a", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
* "test", "reporting", "quadrant-budget-hsql.xaction", null, false, parameterProvider, outputHandler, session);
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ outputStream = getOutputStream("ReportingTest.testBIRTReport1-b", ".pdf");
* //$NON-NLS-1$ //$NON-NLS-2$ outputHandler = new SimpleOutputHandler(outputStream, true);
* parameterProvider.setParameter("type", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ context = run( "test", "reporting",
* "quadrant-budget-hsql.xaction", null, false, parameterProvider, outputHandler, session); //$NON-NLS-1$
* //$NON-NLS-2$ //$NON-NLS-3$ assertEquals( Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
* IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus()); //$NON-NLS-1$ finishTest(); }
*
* public void testBIRTReport4() { startTest(); SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
* parameterProvider.setParameter("REGION", "Eastern"); //$NON-NLS-1$ //$NON-NLS-2$
* parameterProvider.setParameter("DEPARTMENT", "Finance"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
* getOutputStream("ReportingTest.testBIRTReport4", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler
* outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
* "test", "reporting", "quadrant-budget-for-region-and-dept-to-repository.xaction", null, false, parameterProvider,
* outputHandler, session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
*
* public void testBIRTIntparm() { startTest(); SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
* parameterProvider.setParameter("intparm", "300000"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
* getOutputStream("ReportingTest.testIntParm", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler
* outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
* "test", "reporting", "BIRT-quadrant-budget-hsql-intparm.xaction", null, false, parameterProvider, outputHandler,
* session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
*/
/*
* public void testJasperReports1() { startTest(); SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("REGION", "Eastern"); //$NON-NLS-1$ //$NON-NLS-2$
* OutputStream outputStream = getOutputStream("ReportingTest.testJasperReports1", ".html"); //$NON-NLS-1$
* //$NON-NLS-2$ SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession
* session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext
* context = run( "test", "reporting", "jasper-reports-test-1.xaction", null, false, parameterProvider, outputHandler,
* session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
*
* public void testJasperReports2() { startTest(); SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("REGION", "Eastern"); //$NON-NLS-1$ //$NON-NLS-2$
* parameterProvider.setParameter("type", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
* getOutputStream("ReportingTest.testJasperReports2", ".pdf"); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler
* outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
* "test", "reporting", "jasper-reports-test-2.xaction", null, false, parameterProvider, outputHandler, session);
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
*/
/*
* public void testBIRTReport3() { startTest(); SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("type", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream
* outputStream = getOutputStream("ReportingTest.testBIRTReport3", ".pdf"); //$NON-NLS-1$ //$NON-NLS-2$
* SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
* "test", "reporting", "quadrant-budget-for-region-hsql.xaction", null, false, parameterProvider, outputHandler,
* session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ finishTest(); }
*/
public void testActionComponent() {
startTest();
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
IPentahoUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath());
ArrayList messages = new ArrayList();
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("solution", "test");
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("path", "reporting");
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("action", "custom-parameter-page-example.xaction");
ActionComponent component = new ActionComponent("test/reporting/custom-parameter-page-example.xaction", null, IOutputHandler.OUTPUT_TYPE_DEFAULT, urlFactory, // $NON-NLS-1$
messages);
component.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
component.validate(session, null);
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream outputStream = getOutputStream("ReportingTest.testActionComponent", ".html");
// $NON-NLS-1$
String content = component.getContent("text/html");
try {
outputStream.write(content.getBytes());
} catch (Exception e) {
// ignore
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class MetadataIT method __testLoadView.
public void __testLoadView() {
startTest();
// $NON-NLS-1$
IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
PMDUIComponent component = new PMDUIComponent(urlFactory, new ArrayList());
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
component.validate(session, null);
component.setAction(PMDUIComponent.ACTION_LOAD_MODEL);
// $NON-NLS-1$
component.setDomainName("test");
// $NON-NLS-1$
component.setModelId("Orders");
Document doc = component.getXmlContent();
System.out.println(doc.asXML());
try {
// $NON-NLS-1$//$NON-NLS-2$
OutputStream outputStream = getOutputStream("MetadataTest.testLoadView", ".xml");
outputStream.write(doc.asXML().getBytes());
} catch (IOException e) {
// ignore
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class DashboardWidgetIT method testWidget1.
public void testWidget1() {
startTest();
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
ArrayList messages = new ArrayList();
DashboardWidgetComponent widget = new DashboardWidgetComponent(DashboardWidgetComponent.TYPE_DIAL, getSolutionPath() + "/samples/charts/dashboardwidget1.dial.xml", 300, 300, urlFactory, // $NON-NLS-1$
messages);
widget.setLoggingLevel(getLoggingLevel());
widget.setValue(72.5);
// $NON-NLS-1$
widget.setTitle("test widget 1");
// $NON-NLS-1$
widget.setUnits("$");
// $NON-NLS-1$//$NON-NLS-2$
OutputStream outputStream = getOutputStream("DashboardWidgetTest.testWidget1", ".html");
// $NON-NLS-1$
String contentType = "text/html";
SimpleParameterProvider requestParameters = new SimpleParameterProvider();
SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
HashMap parameterProviders = new HashMap();
parameterProviders.put(HttpRequestParameterProvider.SCOPE_REQUEST, requestParameters);
parameterProviders.put(HttpSessionParameterProvider.SCOPE_SESSION, sessionParameters);
// $NON-NLS-1$
StandaloneSession session = new StandaloneSession("BaseTest.DEBUG_JUNIT_SESSION");
SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
try {
widget.validate(session, requestHandler);
widget.handleRequest(outputStream, requestHandler, contentType, parameterProviders);
} catch (IOException e) {
e.printStackTrace();
}
finishTest();
}
use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.
the class GlobalOutputIT method testEmptyActionSequence.
public void testEmptyActionSequence() {
startTest();
List messages = new ArrayList();
String instanceId = null;
IPentahoSession session = new StandaloneSession("system");
PentahoSessionHolder.setSession(session);
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class);
solutionEngine.setLoggingLevel(ILogger.ERROR);
solutionEngine.init(session);
String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
HashMap parameterProviderMap = new HashMap();
IPentahoUrlFactory urlFactory = new SimpleUrlFactory(baseUrl);
try {
File file = new File(getSolutionPath() + "/samples/platform/SetGlobalOutputTest.xaction");
StringBuilder str = new StringBuilder();
Reader 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 = solutionEngine.execute(xactionStr, "SetGlobalOutputTest.xaction", "empty action sequence test", false, true, instanceId, false, parameterProviderMap, null, null, urlFactory, // $NON-NLS-1$ //$NON-NLS-2$
messages);
assertNotNull("RuntimeContext is null", runtimeContext);
assertEquals("Action sequence execution failed", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_SUCCESS);
IParameterProvider provider = PentahoSystem.getGlobalParameters();
// $NON-NLS-1$
String parameter = provider.getStringParameter("GLOBAL_TEST", null);
assertNotNull(parameter);
// $NON-NLS-1$
assertEquals("This is a test", parameter);
} catch (Exception e) {
// we should not get here
e.printStackTrace();
assertTrue(e.getMessage(), false);
}
}
Aggregations