xjavadoc.codeunit

Class CodeTestCase

public abstract class CodeTestCase extends TestCase

CodeTestCase is a JUnit extension that will let you compare two sources (typically one we keep as test data and a generated one) on the API level or on the abstract syntax tree (AST) level. This is a lot more powerful than comparing on a character by character basis, because it's only "what matters" that is compared.

Author: Aslak Hellesxy

UNKNOWN: 24. februar 2003

Constructor Summary
CodeTestCase()
Method Summary
static voidassertApiEquals(File expected, File actual)
Asserts (tests) that the APIs of two sources are equal.
static voidassertApiEquals(Reader expected, Reader actual)
static voidassertApiEquals(SourceClass expected, SourceClass actual)
static voidassertAstEquals(File expected, File actual)
Asserts (tests) that the ASTs of two sources are equal.
static voidassertAstEquals(Reader expected, Reader actual)
static voidassertAstEquals(SimpleNode expected, SimpleNode actual)
static voidassertAstEqualsDir(File expectedDir, File actualDir)
static voidassertConstructorEquals(XConstructor expected, XConstructor actual)
static voidassertConstructorsEqual(XClass expected, XClass actual)
static voidassertEquals(File expected, File actual)
Compares both API and AST.
static voidassertEquals(Reader expected, Reader actual)
static voidassertFieldEquals(XField expected, XField actual)
static voidassertFieldsEqual(XClass expected, XClass actual)
static voidassertInterfacesEqual(SourceClass expected, SourceClass actual)
static voidassertMethodEquals(XMethod expected, XMethod actual)
static voidassertMethodsEqual(XClass expected, XClass actual)
static voidassertModifiersEqual(String msg, XProgramElement expected, XProgramElement actual)
static voidassertNameEquals(String msg, Named expected, Named actual)
static voidassertNameWithSignatureEquals(String msg, XExecutableMember expected, XExecutableMember actual)
static voidassertParameterEquals(XParameter expected, XParameter actual)
static voidassertParametersEqual(String msg, XExecutableMember expected, XExecutableMember actual)
static voidassertSuperclassEquals(SourceClass expected, SourceClass actual)
static voidassertThrownExceptionsEqual(String msg, XExecutableMember expected, XExecutableMember actual)
static voidassertTypeEquals(String msg, Type expected, Type actual)
static voidcheckNotDir(File expected, File actual)
static FilegetActualChild(File actualDir, File expectedChild)
protected FilegetDir()
Returns the directory where this class is located, provided that it's not in a jar.
protected FilegetRootDir()
Returns the root directory of the package hierarchy where this class is located, provided that it's not in a jar.
protected XJavaDocgetXJavaDoc()

Constructor Detail

CodeTestCase

public CodeTestCase()

Method Detail

assertApiEquals

public static void assertApiEquals(File expected, File actual)
Asserts (tests) that the APIs of two sources are equal. Does not go into the method bodies to see if the implementation is equal, and is therefore more relaxed than assertAstEquals.

Parameters: expected the expected source actual the actual source

assertApiEquals

public static void assertApiEquals(Reader expected, Reader actual)

assertApiEquals

private static void assertApiEquals(SourceClass expected, SourceClass actual)

assertAstEquals

public static void assertAstEquals(File expected, File actual)
Asserts (tests) that the ASTs of two sources are equal. Does not compare the contents (tokens) of the nodes, and is forgiving with respect to those.

Parameters: expected the expected source actual the actual source

assertAstEquals

public static void assertAstEquals(Reader expected, Reader actual)

assertAstEquals

private static void assertAstEquals(SimpleNode expected, SimpleNode actual)

assertAstEqualsDir

public static void assertAstEqualsDir(File expectedDir, File actualDir)

assertConstructorEquals

private static void assertConstructorEquals(XConstructor expected, XConstructor actual)

assertConstructorsEqual

private static void assertConstructorsEqual(XClass expected, XClass actual)

assertEquals

public static void assertEquals(File expected, File actual)
Compares both API and AST. Equivalent to calling CodeTestCase and CodeTestCase.

Parameters: expected the expected source actual the actual source

assertEquals

public static void assertEquals(Reader expected, Reader actual)

assertFieldEquals

private static void assertFieldEquals(XField expected, XField actual)

assertFieldsEqual

private static void assertFieldsEqual(XClass expected, XClass actual)

assertInterfacesEqual

private static void assertInterfacesEqual(SourceClass expected, SourceClass actual)

assertMethodEquals

private static void assertMethodEquals(XMethod expected, XMethod actual)

assertMethodsEqual

private static void assertMethodsEqual(XClass expected, XClass actual)

assertModifiersEqual

private static void assertModifiersEqual(String msg, XProgramElement expected, XProgramElement actual)

assertNameEquals

private static void assertNameEquals(String msg, Named expected, Named actual)

assertNameWithSignatureEquals

private static void assertNameWithSignatureEquals(String msg, XExecutableMember expected, XExecutableMember actual)

assertParameterEquals

private static void assertParameterEquals(XParameter expected, XParameter actual)

assertParametersEqual

private static void assertParametersEqual(String msg, XExecutableMember expected, XExecutableMember actual)

assertSuperclassEquals

private static void assertSuperclassEquals(SourceClass expected, SourceClass actual)

assertThrownExceptionsEqual

private static void assertThrownExceptionsEqual(String msg, XExecutableMember expected, XExecutableMember actual)

assertTypeEquals

private static void assertTypeEquals(String msg, Type expected, Type actual)

checkNotDir

private static void checkNotDir(File expected, File actual)

getActualChild

private static File getActualChild(File actualDir, File expectedChild)

getDir

protected File getDir()
Returns the directory where this class is located, provided that it's not in a jar. This is very useful for accessing the files you want to compare.

Returns: the directory where this class is located.

getRootDir

protected File getRootDir()
Returns the root directory of the package hierarchy where this class is located, provided that it's not in a jar. This is very useful for accessing the files you want to compare.

Returns: the root directory.

getXJavaDoc

protected XJavaDoc getXJavaDoc()