com.thoughtworks.qdox.junit

Class APITestCase

public abstract class APITestCase extends TestCase

APITestCase is a JUnit extension that will let you compare two sources (typically one kept as a static expected result and a generated one) on the API level.

This class has been ported from XJavaDoc's CodeTestCase, carrying over only the parts that compare on the API level. The original CodeTestCase also has comparison of Java source AST (Abstract Syntax Trees). This will probably be extracted into a ASTTestCase class and hosted as a separate project somewhere else. It should probably be based on JavaCC for ease of porting.

Author: Aslak Hellesøy Laurent Etiemble

Field Summary
static ComparatorENTITY_COMPARATOR
Constructor Summary
APITestCase()
Method Summary
static voidassertApiEquals(URL expected, URL actual)
Compares API of both sources in the readers.
static voidassertApiEquals(JavaSource expected, JavaSource actual)
Compares API of both JavaSource objects.
static voidassertClassesEqual(JavaClass expected, JavaClass actual)
Compares an actual field to an expected one.
static voidassertFieldEquals(JavaField expected, JavaField actual)
Compares an actual field to an expected one.
static voidassertFieldsEqual(JavaClass expected, JavaClass actual)
Compares fields from an actual class to an expected one.
static voidassertInnerClassesEquals(JavaClass expected, JavaClass actual)
Compares inner classes from an actual class to an expected one.
static voidassertInterfacesEqual(JavaClass expected, JavaClass actual)
Compares implemented interfaces from an actual class to an expected one.
static voidassertMethodsEqual(JavaClass expected, JavaClass actual)
Compares constructors and methods from an actual class to an expected one.
static voidassertModifiersEquals(String msg, AbstractJavaEntity expected, AbstractJavaEntity actual)
Compares modifiers an actual entity.
static voidassertNotDir(File expected, File actual)
protected FilegetDir()
protected FilegetRootDir()

Field Detail

ENTITY_COMPARATOR

private static Comparator ENTITY_COMPARATOR

Constructor Detail

APITestCase

public APITestCase()

Method Detail

assertApiEquals

public static void assertApiEquals(URL expected, URL actual)
Compares API of both sources in the readers.

Note: This method is for backward naming compatiblity with xjavadoc.codeunit.CodeTestCase.

Parameters: expected the expected source actual the actual source

assertApiEquals

private static void assertApiEquals(JavaSource expected, JavaSource actual)
Compares API of both JavaSource objects.

Parameters: expected the expected source actual the actual source

assertClassesEqual

private static void assertClassesEqual(JavaClass expected, JavaClass actual)
Compares an actual field to an expected one.

As JavaClass doesn't not implements equals and hashCode methods, the comparison is done by hand.

Parameters: expected actual

assertFieldEquals

private static void assertFieldEquals(JavaField expected, JavaField actual)
Compares an actual field to an expected one.

As JavaField doesn't not implements equals and hashCode methods, the comparison is done by hand.

Parameters: expected actual

assertFieldsEqual

private static void assertFieldsEqual(JavaClass expected, JavaClass actual)
Compares fields from an actual class to an expected one.

The fields are sorted by name before comparison to be sure that even if the fields are defined in a different order, the comparison is still right.

assertInnerClassesEquals

private static void assertInnerClassesEquals(JavaClass expected, JavaClass actual)
Compares inner classes from an actual class to an expected one.

The inner classes are sorted by name before comparison to be sure that even if the inner classes are defined in a different order, the comparison is still right.

assertInterfacesEqual

private static void assertInterfacesEqual(JavaClass expected, JavaClass actual)
Compares implemented interfaces from an actual class to an expected one.

The implemented interfaces are sorted by name before comparison to be sure that even if the implemented interfaces are defined in a different order, the comparison is still right.

assertMethodsEqual

private static void assertMethodsEqual(JavaClass expected, JavaClass actual)
Compares constructors and methods from an actual class to an expected one.

The constructors and the methods are sorted by name before comparison to be sure that even if the constructors and methods are defined in a different order, the comparison is still right.

assertModifiersEquals

private static void assertModifiersEquals(String msg, AbstractJavaEntity expected, AbstractJavaEntity actual)
Compares modifiers an actual entity.

The modifiers are sorted by name before comparison to be sure that even if the modifiers are defined in a different order, the comparison is still right.

assertNotDir

private static void assertNotDir(File expected, File actual)

getDir

protected File getDir()

getRootDir

protected File getRootDir()