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

import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;

import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTask;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * always get warning when closing getparameter task.
 * <p>
 * <b>Test description</b>
 * <p>
 * This test makes sure that no warning in console when close
 * IGetParameterDefinitionTask.
 * 
 * 
 * 
 */
public class Regression_133230 extends EngineCase
{

	private final static String INPUT = "regression_133230.rptdesign"; //$NON-NLS-1$
	private final static String OUTPUT = "regression_133230_err.txt"; //$NON-NLS-1$
	private String path = getClassFolder( ) + "/";

	/**
	 * @throws Exception
	 */

	public void test_Regression_133230( ) throws Exception
	{
		System.setOut( new PrintStream( new FileOutputStream( path
				+ OUTPUT_FOLDER + "/" + OUTPUT ) ) );
		System.setErr( new PrintStream( new FileOutputStream( path
				+ OUTPUT_FOLDER + "/" + OUTPUT ) ) );

		IReportRunnable reportRunnable = engine.openReportDesign( path
				+ INPUT_FOLDER + "/" + INPUT );
		IGetParameterDefinitionTask task = engine
				.createGetParameterDefinitionTask( reportRunnable );
		task.evaluateQuery( "cascadingGroup" );
		task
				.getSelectionListForCascadingGroup( "cascadingGroup",
						new Object[0] );
		task.close( );
		checkWarning( );
		removeFile( path + OUTPUT );
	}

	private void checkWarning( ) throws IOException
	{
		BufferedReader reader = new BufferedReader( new FileReader( path
				+ OUTPUT_FOLDER + "/" + OUTPUT ) );
		String line = null;
		while ( ( line = reader.readLine( ) ) != null )
		{
			assertTrue( line.indexOf( "1 statements still active" ) == -1 );
		}
	}

}
