use of org.pentaho.platform.uifoundation.component.HtmlComponent in project pentaho-platform by pentaho.
the class HTMLComponentIT method testComponent2.
public void testComponent2() {
startTest();
// $NON-NLS-1$
info(Messages.getInstance().getString("HTMLComponentTest.USER_ERRORS_EXPECTED_CONTENT_TYPE_INVALID"));
// this should fail because the requested content type is not supported
// $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);
component.setLoggingLevel(getLoggingLevel());
// $NON-NLS-1$//$NON-NLS-2$
OutputStream outputStream = getOutputStream("HTMLComponentTest.testComponent2", ".html");
// $NON-NLS-1$
String contentType = "text/xml";
SimpleParameterProvider requestParameters = new SimpleParameterProvider();
SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
HashMap parameterProviders = new HashMap();
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParameters);
parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters);
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
try {
component.validate(session, requestHandler);
component.handleRequest(outputStream, requestHandler, contentType, parameterProviders);
} catch (IOException e) {
e.printStackTrace();
}
finishTest();
}
use of org.pentaho.platform.uifoundation.component.HtmlComponent in project pentaho-platform by pentaho.
the class HTMLComponentIT method testComponent3.
public void testComponent3() {
startTest();
// $NON-NLS-1$
info(Messages.getInstance().getString("HTMLComponentTest.USER_ERRORS_EXPECTED_URL_INVALID"));
// this should fail because the url is bad
// $NON-NLS-1$
String url = "xttp://a";
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
ArrayList messages = new ArrayList();
HtmlComponent component = new HtmlComponent(HtmlComponent.TYPE_URL, url, Messages.getInstance().getString("HTML.ERROR_0001_NOT_AVAILABLE"), urlFactory, // $NON-NLS-1$
messages);
component.setLoggingLevel(getLoggingLevel());
// $NON-NLS-1$//$NON-NLS-2$
OutputStream outputStream = getOutputStream("HTMLComponentTest.testComponent3", ".html");
// $NON-NLS-1$
String contentType = "text/html";
SimpleParameterProvider requestParameters = new SimpleParameterProvider();
SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
HashMap parameterProviders = new HashMap();
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParameters);
parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters);
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
try {
component.validate(session, requestHandler);
component.handleRequest(outputStream, requestHandler, contentType, parameterProviders);
} catch (IOException e) {
e.printStackTrace();
}
finishTest();
}
use of org.pentaho.platform.uifoundation.component.HtmlComponent 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();
}
Aggregations