/*******************************************************************************
 * Copyright (c) 2004 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.test.performance.parser;

import java.util.List;

import junit.framework.TestCase;

public class ParserTest extends TestCase
{

	private static final String TEST1 = "testConfig1.xml"; //$NON-NLS-1$

	public void test( ) throws Exception
	{
		ConfigurationReader
				.parse( ParserTest.class.getResourceAsStream( TEST1 ) );
		Configuration configuration = Configuration.getInstance( );

		testcase1( configuration.getTestCase( "case1" ) );
		testcase2( configuration.getTestCase( "case2" ) );
		testcase3( configuration.getTestCase( "case3" ) );

	}

	private void testcase1( TestCaseNode testcase )
	{
		assertEquals( "10", testcase.getReport( ) ); //$NON-NLS-1$
		List reports1 = testcase.getReports( );
		assertEquals( 1, reports1.size( ) );
		assertEquals(
				"Sample(excludelib).rptdesign", ( (ReportDesignNode) reports1.get( 0 ) ).getName( ) ); //$NON-NLS-1$

	}

	private void testcase2( TestCaseNode testcase )
	{
		assertEquals( "1,2", testcase.getReport( ) );
		List reports2 = testcase.getReports( );
		assertEquals( 2, reports2.size( ) );
		assertEquals(
				"Corporation.rptdesign", ( (ReportDesignNode) reports2.get( 0 ) ).getName( ) ); //$NON-NLS-1$
		assertEquals(
				"OrderReport.rptdesign", ( (ReportDesignNode) reports2.get( 1 ) ).getName( ) ); //$NON-NLS-1$

	}

	private void testcase3( TestCaseNode testcase )
	{
		assertEquals( "1-10", testcase.getReport( ) ); //$NON-NLS-1$
		List reports3 = testcase.getReports( );
		assertEquals( 10, reports3.size( ) );
		assertEquals(
				"Corporation.rptdesign", ( (ReportDesignNode) reports3.get( 0 ) ).getName( ) ); //$NON-NLS-1$
		assertEquals(
				"OrderReport.rptdesign", ( (ReportDesignNode) reports3.get( 1 ) ).getName( ) ); //$NON-NLS-1$
		assertEquals(
				"Sample(excludelib).rptdesign", ( (ReportDesignNode) reports3.get( 9 ) ).getName( ) ); //$NON-NLS-1$

	}
}
