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

import java.util.HashMap;

import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * Use non-existed column binding as sort key will destroy preview
 * <p>
 * <b>Test description</b>
 * <p>
 * This test makes sure that the error will be catched as DataException
 * 
 */

public class Regression_142684 extends EngineCase
{

	private final static String INPUT = "regression_142684.rptdesign"; //$NON-NLS-1$
	private final static String OUTPUT = "regression_142684.html"; //$NON-NLS-1$
	private String inputPath = getClassFolder( )
			+ System.getProperty( "file.separator" ) + INPUT_FOLDER
			+ System.getProperty( "file.separator" );
	private String outputPath = getClassFolder( )
			+ System.getProperty( "file.separator" ) + OUTPUT_FOLDER
			+ System.getProperty( "file.separator" );

	/**
	 * @throws Exception
	 */
	public void test_Regression_142684( ) throws Exception
	{
		IReportRunnable reportRunnable = engine.openReportDesign( inputPath
				+ INPUT );
		IRunAndRenderTask task = engine.createRunAndRenderTask( reportRunnable );
		HTMLRenderOption options = new HTMLRenderOption( );
		options.setOutputFileName( outputPath + OUTPUT );
		options.setOutputFormat( "html" );
		task.setAppContext( new HashMap( ) );
		task.setRenderOption( options );
		task.run( );
		assertTrue( "Exception when generate report.",
				task.getErrors( ).size( ) > 0 );
		assertTrue( "DataException isn't catched.",
				task.getErrors( ).get( 0 ) instanceof DataException );
		task.close( );
	}
}
