
package org.eclipse.birt.report.tests.viewer.regression;

import org.apache.cactus.WebRequest;
import org.eclipse.birt.report.servlet.ViewerServlet;
import org.eclipse.birt.report.tests.viewer.BaseViewerTestCase;

import com.meterware.httpunit.WebResponse;

/**
 * <b>Steps to reproduce:</b>
 * <ol>
 * <li>Create a report
 * <li>Add an data item and set its bookmark
 * <li>Add a parameter in the same report
 * <li>Create another report
 * <li>Add an data item and set its hyperlink
 * <li>In hyperlink builder, select "Drillthrough"
 * <li>Select the parameter
 * </ol>
 * <b>Actual result:</b>
 * <p>
 * Click on "preview" tab. It appears "null"
 * <p>
 * <b>Expected result:</b>
 * <p>
 * Report can be rendered properly
 * </p>
 * <b>Test description:</b>
 * <p>
 * Viewer should handler invalid parameter value properly
 * </p>
 */
public class Regression_122083 extends BaseViewerTestCase
{

	private final static String REPORT = "report/regression_122083.rptdesign";

	/**
	 * @param webRequest
	 * @throws Exception
	 */
	public void begin_regression_122083( WebRequest webRequest )
			throws Exception
	{
		webRequest.setURL( null, null, SERVLET_PATH_FRAMESET, null, null );
		webRequest.addParameter( PARAM_REPORT, REPORT );
		webRequest.addHeader( "request-type", "SOAP" );//$NON-NLS-1$//$NON-NLS-2$
		webRequest.setContentType( "text/xml; charset=utf-8" ); //$NON-NLS-1$
		webRequest.addHeader( "SOAPAction", "''" ); //$NON-NLS-1$//$NON-NLS-2$
		webRequest.setUserData( getPageSoapMessage( "1" ) );
	}

	/**
	 * test_regression_122083
	 */
	public void test_regression_122083( )
	{
		ViewerServlet servlet = new ViewerServlet( );
		try
		{
			servlet.init( config );
			servlet.doPost( request, response );
		}
		catch ( Exception e )
		{
			e.printStackTrace( );
			fail( e.toString( ) );
		}
	}

	/**
	 * @param webResponse
	 */
	public void end_regression_122083( WebResponse webResponse )
			throws Exception
	{
		String content = webResponse.getText( );
		String integerParam = "integerParam=a";
		int sIndex = content.indexOf( integerParam );
		if ( sIndex == -1 )
			fail( "parameter handling error" );
	}

}