gt: 		assertNull( actionHandle.getURI( ) );
context: /*******************************************************************************
   * 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.report.model.api;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import org.eclipse.birt.report.model.api.activity.SemanticException;
  import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
  import org.eclipse.birt.report.model.api.elements.structures.Action;
  import org.eclipse.birt.report.model.api.elements.structures.ParamBinding;
  import org.eclipse.birt.report.model.api.elements.structures.SearchKey;
  import org.eclipse.birt.report.model.api.metadata.PropertyValueException;
  import org.eclipse.birt.report.model.metadata.PropertyDefn;
  import org.eclipse.birt.report.model.util.BaseTestCase;
  
  
  /**
   * TestCases for ActionHandle class. ActionHandle should be got from the
   * specific ElementHandle that contains an Action.
   * <p>
   * <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: * collapse" bordercolor="#111111">
   * <th width="20%">Method</th>
   * <th width="40%">Test Case</th>
   * <th width="40%">Expected</th>
   * 
   * 
   * <tr>
   * <td>{@link #testAddDrillthroughParameter()}</td>
   * <td>Add a new DrillthroughParameter to an Action.</td>
   * <td>The Parameter should be added to the Element that contains Action.</td>
   * </tr>
   * 
   * <tr>
   * <td>{@link #testaddDrillthroughSearchKeys()}</td>
   * <td>Add a new DrillthroughSearchKey to an Action.</td>
   * <td>The SearchKey should be added to the Element that contains Action.</td>
   * </tr>
   * 
   * <tr>
   * <td>{@link #testGetDrillthroughParameters()}</td>
   * <td>The Action is of Drillthrough type and containing 2 parameters.</td>
   * <td>A list contains 2 DrillthroughParameters. And the Expression value of the
   * Parameter is correct</td>
   * </tr>
   * 
   * <tr>
   * <td>{@link #testGetDrillthroughSearchKeys()}</td>
   * <td>The Action is of Drillthrough type and containing 2 searchKeys.</td>
   * <td>A list conains 2 SearchKeys. And the Expression value of the SearchKey is
   * correct</td>
   * </tr>
   * 
   * 
   * <tr>
   * <td>{@link #testGetLinkExpr()}</td>
   * <td>Action is represented by a Hyperlink.</td>
   * <td>LinkExpression should be the value of the Hyperlink.</td>
   * </tr>
   * 
   * <tr>
   * <td></td>
   * <td>Action is represented by a Drillthrough.</td>
   * <td>LinkExpression should be the value of the BookmarkLink for the
   * Drillthrough.</td>
   * </tr>
   * 
   * <tr>
   * <td></td>
   * <td>Action is represented by a BookmarkLink.</td>
   * <td>LinkExpression should be the value of the BookmarkLink.</td>
   * </tr>
   * 
   * <tr>
   * <td>{@link #testGetLinkType()}</td>
   * <td>Action is represented by a Hyperlink.</td>
   * <td>LinkType should be Hyperlink.</td>
   * </tr>
   * 
   * <tr>
   * <td></td>
   * <td>Action is represented by a Drillthrough.</td>
   * <td>LinkType should be Drillthrough.</td>
   * </tr>
   * 
   * <tr>
   * <td></td>
   * <td>Action is represented by a BookmarkLink.</td>
   * <td>LinkType should be BookmarkLink.</td>
   * </tr>
   * 
   * <tr>
   * <td>{@link #testSetLinkExpr()}</td>
   * <td>Action is represented by a Hyperlink. Set its Link Expression.</td>
   * <td>Value of the Expression is properly set.</td>
   * </tr>
   * 
   * </table>
   * 
   */
  public class ActionHandleTest extends BaseTestCase
  {
  
  	ActionHandle actionHandle = null;
  	private static final String fileName = "ActionHandleTest_5.xml"; //$NON-NLS-1$
  
  	protected void setUp( ) throws Exception
  	{
  		super.setUp( );
  		openDesign( "ActionHandleTest.xml" ); //$NON-NLS-1$
  		assertNotNull( designHandle );
  	}
  
  	/**
  	 * Get an related ActionHandle for the action defined on an image.
  	 */
  
  	private ActionHandle getAction( String imageName )
  	{
  		ImageHandle imageHandle = (ImageHandle) designHandle
  				.findElement( imageName );
  		assertNotNull( imageHandle );
  		return imageHandle.getActionHandle( );
  	}
  
  	/**
  	 * 
  	 * @throws Exception
  	 */
  	public void testAdd( ) throws Exception
  	{
  		openDesign( "ActionHandleTest2.xml" ); //$NON-NLS-1$
  
  		ImageHandle imageHandle = (ImageHandle) designHandle
  				.findElement( "Image1" ); //$NON-NLS-1$
  		ActionHandle actionHandle = imageHandle.getActionHandle( );
  
  		MemberHandle memberHandle = actionHandle.getParamBindings( );
  		assertEquals( 1, memberHandle.getListValue( ).size( ) );
  		assertEquals(
  				"exp0", ( (ParamBindingHandle) memberHandle.getAt( 0 ) ).getExpression( ) ); //$NON-NLS-1$
  
  		memberHandle.removeItem( 0 );
  		assertNull( memberHandle.getListValue( ) );
  
  		Action action = StructureFactory.createAction( );
  		actionHandle = imageHandle.setAction( action );
  
  		// default is hyperlink.
  		assertEquals( DesignChoiceConstants.ACTION_LINK_TYPE_HYPERLINK,
  				actionHandle.getLinkType( ) );
  		actionHandle.setReportName( "report-name1" ); //$NON-NLS-1$
  
  		// switch to drill-through
  		actionHandle
  				.setLinkType( DesignChoiceConstants.ACTION_LINK_TYPE_DRILL_THROUGH );
  		SearchKey key1 = StructureFactory.createSearchKey( );
  		key1.setExpression( "Key1" ); //$NON-NLS-1$
  		SearchKey key2 = StructureFactory.createSearchKey( );
  		key2.setExpression( "Key2" ); //$NON-NLS-1$
  
  		actionHandle.addSearch( key1 );
  		actionHandle.addSearch( key2 );
  
  		ParamBinding param1 = StructureFactory.createParamBinding( );
  		param1.setExpression( "exp1" ); //$NON-NLS-1$
  		param1.setParamName( "param1" ); //$NON-NLS-1$
  
  		ParamBinding param2 = StructureFactory.createParamBinding( );
  		param2.setExpression( "exp2" ); //$NON-NLS-1$
  		param2.setParamName( "param2" ); //$NON-NLS-1$
  
  		actionHandle.addParamBinding( param1 ); // one way
  		actionHandle.getParamBindings( ).addItem( param2 ); // another way.
  
  		save( );
  		assertTrue( compareFile( "ActionHandleTest2_golden.xml" ) ); //$NON-NLS-1$
  	}
  
  	/**
  	 * Case1: Action is represented by a Hyperlink. LinkExpression should be the
  	 * value of the Hyperlink.
  	 * <p>
  	 * Case2: Action is represented by a Drillthrough. LinkExpression should be
  	 * the value of the BookmarkLink for the Drillthrough.
  	 * <p>
  	 * Case3: Action is represented by a BookmarkLink. LinkExpression should be
  	 * the value of the BookmarkLink.
  	 * 
  	 * @throws Exception
  	 */
  
  	public void testGetLinkExpr( ) throws Exception
  	{
  		// 1
  		actionHandle = getAction( "Image1" ); //$NON-NLS-1$
  
  		assertEquals( "www.rock.com.cn/haha/test.html", actionHandle.getURI( ) ); //$NON-NLS-1$
  		assertNull( actionHandle.getTargetBookmark( ) );
  
  		Iterator iter = actionHandle.paramBindingsIterator( );
  		assertFalse( iter.hasNext( ) );
  
  		iter = actionHandle.searchIterator( );
  		assertFalse( iter.hasNext( ) );
  
  		// 2
  		actionHandle = getAction( "Image2" ); //$NON-NLS-1$
  		assertEquals(
  				"www.rock.com/bookmarks/1.jsp", actionHandle.getTargetBookmark( ) ); //$NON-NLS-1$
  
  		// 3
  		actionHandle = getAction( "Image4" ); //$NON-NLS-1$
  		assertEquals(
  				"www.rock.com.cn/haha/index.html/bookmarklink1", actionHandle.getTargetBookmark( ) ); //$NON-NLS-1$
  	}
  
  	/**
  	 * test setLinkExpr().
  	 * 
  	 * @throws SemanticException
  	 */
  
  	public void testSetLinkExpr( ) throws SemanticException
  	{
  		actionHandle = getAction( "Image1" ); //$NON-NLS-1$
  
  		// hyperlink
  		actionHandle.setURI( "http://birt.eclipse.org/" ); //$NON-NLS-1$
  		actionHandle
  				.setLinkType( DesignChoiceConstants.ACTION_LINK_TYPE_HYPERLINK );
  		assertEquals( "http://birt.eclipse.org/", actionHandle.getURI( ) ); //$NON-NLS-1$
  		assertNull( actionHandle.getTargetBookmark( ) );
  
  		// bookmark
  		actionHandle.setTargetBookmark( "Bookmark1" ); //$NON-NLS-1$
  		actionHandle
  				.setLinkType( DesignChoiceConstants.ACTION_LINK_TYPE_BOOKMARK_LINK );
  		assertEquals( "Bookmark1", actionHandle.getTargetBookmark( ) ); //$NON-NLS-1$
  		assertEquals( DesignChoiceConstants.ACTION_LINK_TYPE_BOOKMARK_LINK,
  				actionHandle.getLinkType( ) );
  