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

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

import com.meterware.httpunit.WebResponse;

/**
 * <b>Steps to reproduce:</b>
 * <ol>
 * <li>Create a parameter, and enter Actuate
 * <li>Preview in HTML
 * </ol>
 * <b>Actual result:</b>
 * <p>
 * String Actuate cannot be accepted
 * <p>
 * <b>Expected result:</b>
 * <p>
 * String Actuate is accepted
 * </p>
 * <b>Test description:</b>
 * <p>
 * Verify that parameter value can be accepted as string
 * </p>
 */
public class Regression_77838 extends BaseViewerTestCase
{

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

	/**
	 * @param webRequest
	 * @throws Exception
	 */
	public void begin_regression_77838( WebRequest webRequest )
			throws Exception
	{
		webRequest.setURL( null, null, SERVLET_PATH_RUN, null, null );
		webRequest.addParameter( PARAM_REPORT, REPORT );
	}

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

	/**
	 * @param webResponse
	 */
	public void end_regression_77838( WebResponse webResponse )
			throws Exception
	{
		String title = "PARAMETER SELECTION PAGE";
		assertEquals( title, webResponse.getTitle( ) );

		String content = webResponse.getText( );
		String name = "NAME=\"stringParam\"";
		String value = "VALUE=\"actuate\"";
		int index1 = content.indexOf( name );
		int index2 = content.indexOf( value );
		if ( index1 == -1 || index2 == -1 )
			fail( "fail to get default value" );
	}

}