net.sourceforge.groboutils.junit.v1
Class AssertConstructor

java.lang.Object
  extended bynet.sourceforge.groboutils.junit.v1.AssertConstructor

public class AssertConstructor
extends java.lang.Object

A set of assert methods that test a class for implementation of specific constructor types.

Since:
July 21, 2002
Version:
$Date: 2003/02/10 22:52:19 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Field Summary
static int ANY_PROTECTION
          Bit-mask that allows the constructor to have any protection.
static int PACKAGE
          Bit-mask that allows for the constructor to have package-private access.
static int PRIVATE
          Bit-mask that allows for the constructor to have private access.
static int PROTECTED
          Bit-mask that allows for the constructor to have protected access.
static int PUBLIC
          Bit-mask that allows for the constructor to have public access.
 
Constructor Summary
AssertConstructor()
           
 
Method Summary
static void assertHasConstructor(java.lang.Class c, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.Class c, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.Object o, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.Object o, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.String message, java.lang.Class c, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.String message, java.lang.Class c, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.String message, java.lang.Object o, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasConstructor(java.lang.String message, java.lang.Object o, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasDefaultConstructor(java.lang.Class c)
          Ensures that the class c has a default (no-arg), public constructor.
static void assertHasDefaultConstructor(java.lang.Object o)
          Ensures that the class for object o has a default (no-arg), public constructor.
static void assertHasDefaultConstructor(java.lang.String message, java.lang.Class c)
          Ensures that the class c has a default (no-arg), public constructor.
static void assertHasDefaultConstructor(java.lang.String message, java.lang.Object o)
          Ensures that the class for object o has a default (no-arg), public constructor.
static void assertHasSameConstructor(java.lang.Class c, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.Class c, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.Object o, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.Object o, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.String message, java.lang.Class c, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.String message, java.lang.Class c, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.String message, java.lang.Object o, java.lang.Class[] arguments)
          Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static void assertHasSameConstructor(java.lang.String message, java.lang.Object o, java.lang.Class[] arguments, int protection)
          Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.
static java.lang.reflect.Constructor getConstructor(java.lang.Class c, java.lang.Class[] arguments, int protection)
          Retrieves the first constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list, or null if there is no such constructor.
static java.lang.reflect.Constructor getSameConstructor(java.lang.Class c, java.lang.Class[] arguments, int protection)
          Retrieves the constructor in class c that accepts the exact argument list given in arguments, or null if there is no such constructor.
protected static boolean hasCorrectProtection(java.lang.reflect.Constructor cntr, int protection)
           
protected static boolean isInheritedParameters(java.lang.reflect.Constructor cntr, java.lang.Class[] arguments)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC

public static final int PUBLIC
Bit-mask that allows for the constructor to have public access.

See Also:
Constant Field Values

PROTECTED

public static final int PROTECTED
Bit-mask that allows for the constructor to have protected access.

See Also:
Constant Field Values

PACKAGE

public static final int PACKAGE
Bit-mask that allows for the constructor to have package-private access.

See Also:
Constant Field Values

PRIVATE

public static final int PRIVATE
Bit-mask that allows for the constructor to have private access.

See Also:
Constant Field Values

ANY_PROTECTION

public static final int ANY_PROTECTION
Bit-mask that allows the constructor to have any protection.

See Also:
Constant Field Values
Constructor Detail

AssertConstructor

public AssertConstructor()
Method Detail

assertHasDefaultConstructor

public static void assertHasDefaultConstructor(java.lang.String message,
                                               java.lang.Class c)
Ensures that the class c has a default (no-arg), public constructor.

Parameters:
message - message that describes what failed if the assertion fails.
c - the class check for a constructor.

assertHasDefaultConstructor

public static void assertHasDefaultConstructor(java.lang.Class c)
Ensures that the class c has a default (no-arg), public constructor.

Parameters:
c - the class check for a constructor.

assertHasDefaultConstructor

public static void assertHasDefaultConstructor(java.lang.String message,
                                               java.lang.Object o)
Ensures that the class for object o has a default (no-arg), public constructor.

Parameters:
message - message that describes what failed if the assertion fails.
o - the object to check the class's constructor.

assertHasDefaultConstructor

public static void assertHasDefaultConstructor(java.lang.Object o)
Ensures that the class for object o has a default (no-arg), public constructor.

Parameters:
o - the object to check the class's constructor.

assertHasConstructor

public static void assertHasConstructor(java.lang.String message,
                                        java.lang.Class c,
                                        java.lang.Class[] arguments,
                                        int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
message - message that describes what failed if the assertion fails.
c - the class check for a constructor.
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasConstructor( String, Class, Class[] ), assertHasConstructor( String, Object, Class[], int ), assertHasSameConstructor( String, Class, Class[], int )

assertHasConstructor

public static void assertHasConstructor(java.lang.Class c,
                                        java.lang.Class[] arguments,
                                        int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasConstructor( Class, Class[] ), assertHasConstructor( Object, Class[], int ), assertHasSameConstructor( Class, Class[], int )

assertHasConstructor

public static void assertHasConstructor(java.lang.String message,
                                        java.lang.Class c,
                                        java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasConstructor( String, Class, Class[], int ), assertHasConstructor( String, Object, Class[] ), assertHasSameConstructor( String, Class, Class[] )

assertHasConstructor

public static void assertHasConstructor(java.lang.Class c,
                                        java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasConstructor( Class, Class[], int ), assertHasConstructor( Object, Class[] ), assertHasSameConstructor( Class, Class[] )

assertHasConstructor

public static void assertHasConstructor(java.lang.String message,
                                        java.lang.Object o,
                                        java.lang.Class[] arguments,
                                        int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasConstructor( String, Object, Class[] ), assertHasConstructor( String, Class, Class[], int ), assertHasSameConstructor( String, Object, Class[], int )

assertHasConstructor

public static void assertHasConstructor(java.lang.Object o,
                                        java.lang.Class[] arguments,
                                        int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasConstructor( Object, Class[] ), assertHasConstructor( Class, Class[], int ), assertHasSameConstructor( Object, Class[], int )

assertHasConstructor

public static void assertHasConstructor(java.lang.String message,
                                        java.lang.Object o,
                                        java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasConstructor( String, Object, Class[], int ), assertHasConstructor( String, Class, Class[] ), assertHasSameConstructor( String, Object, Class[] )

assertHasConstructor

public static void assertHasConstructor(java.lang.Object o,
                                        java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasConstructor( Object, Class[], int ), assertHasConstructor( Class, Class[] ), assertHasSameConstructor( Object, Class[] )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.String message,
                                            java.lang.Class c,
                                            java.lang.Class[] arguments,
                                            int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasSameConstructor( String, Class, Class[] ), assertHasSameConstructor( String, Object, Class[], int ), assertHasConstructor( String, Class, Class[], int )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.Class c,
                                            java.lang.Class[] arguments,
                                            int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasSameConstructor( Class, Class[] ), assertHasSameConstructor( Object, Class[], int ), assertHasConstructor( Class, Class[], int )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.String message,
                                            java.lang.Class c,
                                            java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasSameConstructor( String, Class, Class[], int ), assertHasSameConstructor( String, Object, Class[] ), assertHasConstructor( String, Class, Class[] )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.Class c,
                                            java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasSameConstructor( Class, Class[], int ), assertHasSameConstructor( Object, Class[] ), assertHasConstructor( Class, Class[] )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.String message,
                                            java.lang.Object o,
                                            java.lang.Class[] arguments,
                                            int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasSameConstructor( String, Object, Class[] ), assertHasSameConstructor( String, Class, Class[], int ), assertHasConstructor( String, Object, Class[], int )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.Object o,
                                            java.lang.Class[] arguments,
                                            int protection)
Ensures that there exists a constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
assertHasSameConstructor( Object, Class[] ), assertHasSameConstructor( Class, Class[], int ), assertHasConstructor( Object, Class[], int )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.String message,
                                            java.lang.Object o,
                                            java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasSameConstructor( String, Object, Class[], int ), assertHasSameConstructor( String, Class, Class[] ), assertHasConstructor( String, Object, Class[] )

assertHasSameConstructor

public static void assertHasSameConstructor(java.lang.Object o,
                                            java.lang.Class[] arguments)
Ensures that there exists a public constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
See Also:
assertHasSameConstructor( Object, Class[], int ), assertHasSameConstructor( Class, Class[] ), assertHasConstructor( Object, Class[] )

getConstructor

public static java.lang.reflect.Constructor getConstructor(java.lang.Class c,
                                                           java.lang.Class[] arguments,
                                                           int protection)
Retrieves the first constructor in class c that accepts the same number of arguments given in arguments, and that the constructor has the same class or an instance of the class in each position of the argument list, or null if there is no such constructor.

Parameters:
arguments - list of classes which the constructor must have as parameters, or subclasses of the arguments. A null argument index indicates that any type is allowed (equivalent to specifying Object.class in the argument). If the array is null, then the argument list will only match the default (no-argument) constructor (which is the same as setting arguments to new Class[0]).
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
getSameConstructor( Class, Class[], int )

getSameConstructor

public static java.lang.reflect.Constructor getSameConstructor(java.lang.Class c,
                                                               java.lang.Class[] arguments,
                                                               int protection)
Retrieves the constructor in class c that accepts the exact argument list given in arguments, or null if there is no such constructor.

Parameters:
protection - a bitwise ORed value containing one or more of the constants PUBLIC, PROTECTED, PACKAGE, or PRIVATE.
See Also:
Class.getConstructor( Class[] )

isInheritedParameters

protected static boolean isInheritedParameters(java.lang.reflect.Constructor cntr,
                                               java.lang.Class[] arguments)

hasCorrectProtection

protected static boolean hasCorrectProtection(java.lang.reflect.Constructor cntr,
                                              int protection)


Copyright © 2001-2003 by The GroboUtils Project