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

import org.eclipse.birt.core.archive.FileArchiveWriter;
import org.eclipse.birt.core.archive.IDocArchiveWriter;
import org.eclipse.birt.report.engine.api.IDataExtractionTask;
import org.eclipse.birt.report.engine.api.IExtractionResults;
import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IResultMetaData;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.birt.report.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * Data in old report cannot be exported.
 * <p>
 * <b>Test description</b>
 * <p>
 * This test makes sure that No exception when export data from report simulated
 * from bug attached file.
 * 
 * 
 * 
 */
public class Regression_136786 extends EngineCase
{

	private final static String INPUT = "regression_136786.rptdesign"; //$NON-NLS-1$
	private final static String OUTPUT = "regression_136786.rptdocument"; //$NON-NLS-1$

	/**
	 * @throws Exception
	 */

	public void test_Regression_136786( ) throws Exception
	{
		String path = getClassFolder( ) + "/" + INPUT_FOLDER + "/";
		IReportRunnable reportRunnable = engine.openReportDesign( path + INPUT );
		IRunTask runTask = engine.createRunTask( reportRunnable );
		IDocArchiveWriter archive = new FileArchiveWriter( path + OUTPUT );
		runTask.run( archive );
		assertTrue( runTask.getErrors( ).size( ) <= 0 );
		runTask.close( );

		IReportDocument reportDocument = engine.openReportDocument( path
				+ OUTPUT );
		IDataExtractionTask task = engine
				.createDataExtractionTask( reportDocument );
		task.selectResultSet( "ELEMENT_16" );
		IExtractionResults results = task.extract( );
		IResultMetaData metaData = results.getResultMetaData( );
		assertNotNull( metaData );
		assertEquals( 2, metaData.getColumnCount( ) );
		assertTrue( task.getErrors( ).size( ) <= 0 );
		task.close( );

	}

}
