
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 report
 * <li>Add a label and edit its hyperlink
 * <li>Let it link to another report's bookmark
 * <li>Preview in HTML and click on the label
 * </ol>
 * <b>Actual result:</b>
 * <p>
 * HTTP 500 Error
 * <p>
 * <b>Expected result:</b>
 * <p>
 * Target report can be linked properly
 * </p>
 * <b>Test description:</b>
 * <p>
 * This test maily ensure that the html hyperlink tag is rendered correctly. We
 * make a request to run a report, server returns the content, make sure the
 * hyperlink defined on label is correct.
 * </p>
 */
public class Regression_120058 extends BaseViewerTestCase
{

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

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

	/**
	 * test_regression_120058
	 */
	public void test_regression_120058( )
	{
		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_120058( WebResponse webResponse )
			throws Exception
	{
		String hyperlink = getHyperlink( webResponse, "drill through link" );
		String report = getRuntimeFolder( )
				+ "report/regression_120058b.rptdesign";
		assertEquals( report, getReportParam( hyperlink ) );
		assertEquals( "html", getFormatParam( hyperlink ) );
		assertEquals( "en_US", getLocaleParam( hyperlink ) );
		assertEquals( "true", getMasterpageParam( hyperlink ) );
	}

}