
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>Description:</b>
 * <p>
 * Parameter except string type will cause HTTP 500 error
 * <p>
 * <b>Steps to reproduce:</b>
 * <ol>
 * <li>Create a report
 * <li>Add a parameter of type boolean
 * <li>Set its default value as true
 * <li>Preview report
 * </ol>
 * <b>Actual result:</b>
 * <p>
 * HTTP 500 Error
 * <p>
 * <b>Expected result:</b>
 * <p>
 * Report can be rendered properly
 * </p>
 * <b>Test description:</b>
 * <p>
 * The test report contains a parameter, named "param", type is boolean and
 * default to "false", make sure the report can be correctly rendered.
 * </p>
 */
public class Regression_139349 extends BaseViewerTestCase
{

	private final static String REPORT = "report/regression_139349.rptdesign"; //$NON-NLS-1$

	/**
	 * @param webRequest
	 * @throws Exception
	 */
	public void begin_regression_139349( WebRequest webRequest )
			throws Exception
	{
		webRequest.setURL( null, null, SERVLET_PATH_FRAMESET, null, null );
		webRequest.addParameter( PARAM_REPORT, REPORT );
		webRequest.addParameter( "param", "false" ); //$NON-NLS-1$//$NON-NLS-2$
		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_139349
	 */
	public void test_regression_139349( )
	{
		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_139349( WebResponse webResponse )
			throws Exception
	{
		assertEquals( 200, webResponse.getResponseCode( ) );
	}

}