    1   /*
    2    * Copyright (c) 2001-2003 The XDoclet team
    3    * All rights reserved.
    4    */
    5   package xjavadoc;
    6
    7   import java.io.File;
    8   import junit.framework.AssertionFailedError;
    9   import xjavadoc.codeunit.CodeTestCase;
    10
    11  /***
    12   * This is an example of how to extend CodeTestCase, a very handy extension of
    13   * JUnit's TestCase class. It is intended to be used to test the output of
    14   * generators like XDocletImpl, Middlegen, AndroMDA and I'm sure there are
    15   * more... You want to verify that the code you're generating is ok, don't you?
    16   *
    17   * @author    <a href="aslak.hellesoy at bekk.no">Aslak Helles&oslash;y</a>
    18   * @created   17. oktober 2002
    19   */
    20  public final class CodeTest extends CodeTestCase
    21  {
    22  	// the classes are under xjavadoc/build/regular/classes or
    23  	// xjavadoc/build/unicode/classes , so we walk two dirs up.
    24
    25  	private final File t1 = new File( getRootDir().getParentFile().getParentFile(), "test/codeunit/CodeUnit1.java" );
    26  	private final File t2 = new File( getRootDir().getParentFile().getParentFile(), "test/codeunit/CodeUnit2.java" );
    27  	private final File t3 = new File( getRootDir().getParentFile().getParentFile(), "test/codeunit/CodeUnit3.java" );
    28  	private final File t4 = new File( getRootDir().getParentFile().getParentFile(), "test/codeunit/CodeUnit4.java" );
    29
    30  	public void testT1SameApiAsT2() throws Exception
    31  	{
    32  		assertApiEquals( t1, t2 );
    33  	}
    34
    35  	public void testT1DifferentAstFromT2() throws Exception
    36  	{
    37  		try
    38  		{
    39  			assertAstEquals( t1, t2 );
    40  			fail( "The ASTs should not be equal" );
    41  		}
    42  		catch( AssertionFailedError e )
    43  		{
    44  			// ok
    45  		}
    46  	}
    47
    48  	public void testT3SameApiAsT4() throws Exception
    49  	{
    50  		assertApiEquals( t3, t4 );
    51  	}
    52  }