/*******************************************************************************
 * Copyright (c) 2006 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.chart.tests.script;

import java.io.FileInputStream;
import java.io.InputStream;

import junit.framework.TestCase;

import org.eclipse.birt.chart.script.api.IChart;
import org.eclipse.birt.chart.script.api.IChartWithAxes;
import org.eclipse.birt.chart.script.api.IChartWithoutAxes;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.simpleapi.IReportDesign;

/**
 * 
 */

public abstract class BaseChartTestCase extends TestCase
{

	private IChart cwa;
	private IChart cwo;
	private IReportDesign design;

	private static final String REPORT_PATH = "src/org/eclipse/birt/chart/tests/script/api_test.rptdesign";

	protected void setUp( ) throws Exception
	{
		DesignEngine engine = new DesignEngine( new DesignConfig( ) );
		InputStream ins = new FileInputStream( REPORT_PATH );
		design = engine.openDesign( REPORT_PATH, ins, null );
		// SessionHandle sessionHandle = engine.newSessionHandle(
		// ULocale.getDefault( ) );
		// ReportDesignHandle designHandle = sessionHandle.openDesign(
		// REPORT_PATH );
		// ExtendedItemHandle eih = (ExtendedItemHandle)
		// designHandle.findElement( elementName );
		// return (IChart) eih.getReportItem( ).getSimpleElement( );
		cwa = (IChart) getReportDesign( ).getReportElement( "ChartWithAxes" );
		cwo = (IChart) getReportDesign( ).getReportElement( "ChartWithoutAxes" );
	}

	protected IReportDesign getReportDesign( )
	{
		return design;
	}

	protected IChartWithAxes getChartWithAxes( )
	{
		return (IChartWithAxes) cwa;
	}

	protected IChartWithoutAxes getChartWithoutAxes( )
	{
		return (IChartWithoutAxes) cwo;
	}

}

@@ -629,16 +629,37 @@
 tStream;
+%0Aimport java.net.URL;
 %0A%0Aimport
@@ -1224,48 +1224,8 @@
  = %22
-src/org/eclipse/birt/chart/tests/script/
 api_
@@ -1358,108 +1358,147 @@
 ;%0A%09%09
-InputStream ins = new FileInputStream( REPORT_PATH );%0A%09%09design = engine.openDesign( REPORT_PATH, ins
+URL url = getClass( ).getResource( REPORT_PATH );%0A%09%09if ( url != null )%0A%09%09%7B%0A%09%09%09design = engine.openDesign( url.getFile( ), url.openStream( )
 , nu
@@ -1499,24 +1499,25 @@
  ), null );%0A
+%09
 %09%09// Session
@@ -1566,16 +1566,17 @@
 ndle(%0A%09%09
+%09
 // ULoca
@@ -1591,24 +1591,25 @@
 fault( ) );%0A
+%09
 %09%09// ReportD
@@ -1663,16 +1663,17 @@
 sign(%0A%09%09
+%09
 // REPOR
@@ -1678,24 +1678,25 @@
 ORT_PATH );%0A
+%09
 %09%09// Extende
@@ -1736,16 +1736,17 @@
 ndle)%0A%09%09
+%09
 // desig
@@ -1781,16 +1781,17 @@
 Name );%0A
+%09
 %09%09// ret
@@ -1847,16 +1847,17 @@
 t( );%0A%09%09
+%09
 cwa = (I
@@ -1919,16 +1919,17 @@
 xes%22 );%0A
+%09
 %09%09cwo = 
@@ -1996,16 +1996,20 @@
 xes%22 );%0A
+%09%09%7D%0A
 %09%7D%0A%0A%09pro

Fix chart unit test fail because of wrong path of report design file