
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.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * JavaScript Methods Called by Report Element.
 * <p>
 * <b>Test description:</b>
 * <p>
 * This test makes sure that all methods of report are called when generate a
 * report.
 */

public class Regression_95983 extends EngineCase
{

	private final static String INPUT = "regression_95983.rptdesign";
	private final static String OUTPUT = "regression_95983.html";

	public void test_Regression_95983( ) throws Exception
	{
		System.setOut( new PrintStream( new FileOutputStream( getClassFolder( )
				+ "/" + OUTPUT_FOLDER + "/regression_95983_out.txt" ) ) );
		runAndRender_HTML( INPUT, OUTPUT );
		checkMethods( );
	}

	private void checkMethods( ) throws IOException
	{
		BufferedReader reader = new BufferedReader( new FileReader(
				getClassFolder( ) + "/" + OUTPUT_FOLDER
						+ "/regression_95983_out.txt" ) );
		int count = 0;
		String line = null;
		while ( ( line = reader.readLine( ) ) != null )
		{
			if ( line.equals( "initialize" ) )
				count++;
			if ( line.equals( "beforeFactory" ) )
				count++;
			if ( line.equals( "beforeRender" ) )
				count++;
			if ( line.equals( "afterRender" ) )
				count++;
			if ( line.equals( "afterFactory" ) )
				count++;
		}
		assertEquals( 5, count );
	}
}