|| tc == CL_MAX_PR_TYPE__ARRAY
|| tc == CL_MIN_PR_TYPE__ARRAY) {
cl_copy = new Class[cl.length];
System.arraycopy(cl, 0, cl_copy, 0, cl.length);
}
InvocationConstraint ic = null;
try {
if ( tc == CL_MAX_PR_TYPE__CLASS
|| tc == CL_MAX_PR_TYPE__CLASS__NULL) {
// Invoking ClientMaxPrincipalType(Class clazz) constructor
ic = new ClientMaxPrincipalType((Class) cl[0]);
} else if (tc == CL_MIN_PR_TYPE__CLASS
|| tc == CL_MIN_PR_TYPE__CLASS__NULL) {
// Invoking ClientMinPrincipalType(Class clazz) constructor
ic = new ClientMinPrincipalType((Class) cl[0]);
} else if (tc == CL_MAX_PR_TYPE__ARRAY
|| tc == CL_MAX_PR_TYPE__ARRAY__NULL
|| tc == CL_MAX_PR_TYPE__ARRAY__NULL_EL
|| tc == CL_MAX_PR_TYPE__ARRAY__EMPTY
|| tc == CL_MAX_PR_TYPE__ARRAY__PRIM_TYPE
|| tc == CL_MAX_PR_TYPE__ARRAY__ARRAY_TYPE
|| tc == CL_MAX_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
// Invoking ClientMaxPrincipalType(Class[] classes) constructor
ic = new ClientMaxPrincipalType((Class[]) cl);
} else if (tc == CL_MIN_PR_TYPE__ARRAY
|| tc == CL_MIN_PR_TYPE__ARRAY__NULL
|| tc == CL_MIN_PR_TYPE__ARRAY__NULL_EL
|| tc == CL_MIN_PR_TYPE__ARRAY__EMPTY
|| tc == CL_MIN_PR_TYPE__ARRAY__PRIM_TYPE
|| tc == CL_MIN_PR_TYPE__ARRAY__ARRAY_TYPE
|| tc == CL_MIN_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
// Invoking ClientMinPrincipalType(Class[] classes) constructor
ic = new ClientMinPrincipalType((Class[]) cl);
}
// If some Exception is expected
if ( tc == CL_MAX_PR_TYPE__CLASS__NULL
|| tc == CL_MIN_PR_TYPE__CLASS__NULL
|| tc == CL_MAX_PR_TYPE__ARRAY__NULL
|| tc == CL_MAX_PR_TYPE__ARRAY__NULL_EL
|| tc == CL_MAX_PR_TYPE__ARRAY__EMPTY
|| tc == CL_MAX_PR_TYPE__ARRAY__PRIM_TYPE
|| tc == CL_MAX_PR_TYPE__ARRAY__ARRAY_TYPE
|| tc == CL_MAX_PR_TYPE__ARRAY__NOT_PRINCIPAL
|| tc == CL_MIN_PR_TYPE__ARRAY__NULL
|| tc == CL_MIN_PR_TYPE__ARRAY__NULL_EL
|| tc == CL_MIN_PR_TYPE__ARRAY__EMPTY
|| tc == CL_MIN_PR_TYPE__ARRAY__PRIM_TYPE
|| tc == CL_MIN_PR_TYPE__ARRAY__ARRAY_TYPE
|| tc == CL_MIN_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
logger.log(Level.FINE, "Expected Exception type:: " + ex);
throw new TestException("Instead of " + ex + " no Exception"
+ " has been thrown while invoking constructor");
}
} catch (Exception e) {
logger.log(Level.FINE, "Exception while invoking constructor " + e);
// If no Exception is expected
if ( tc == CL_MAX_PR_TYPE__CLASS
|| tc == CL_MIN_PR_TYPE__CLASS
|| tc == CL_MAX_PR_TYPE__ARRAY
|| tc == CL_MIN_PR_TYPE__ARRAY) {
throw new TestException("Exception while invoking constructor ",
e);
}
// If some Exception is expected
if (!ex.equals(e.getClass())) {
logger.log(Level.FINE, "Expected Exception:: " + ex);
logger.log(Level.FINE, "Thrown Exception:: " + e.getClass());
throw new TestException("Instead of " + ex + " "
+ e.getClass() + " has been thrown while"
+ " invoking constructor");
} else {
return;
}
}
// logger.log(Level.INFO, "Returned object: " + ic.toString());
/*
* Verify that the corresponding constraint object is created.
*/
if (ic == null) {
logger.log(Level.FINE, "Constraint object hasn't been created");
throw new TestException("Constraint object hasn't been created");
}
if ( (tc == CL_MAX_PR_TYPE__CLASS
|| tc == CL_MAX_PR_TYPE__ARRAY)
&& !(ic instanceof ClientMaxPrincipalType)) {
logger.log(Level.FINE,
"Instead of ClientMaxPrincipalType " + ic.getClass()
+ " object is returned");
throw new TestException("Instead of ClientMaxPrincipalType "
+ ic.getClass() + " object is returned");
} else if ((tc == CL_MIN_PR_TYPE__CLASS
|| tc == CL_MIN_PR_TYPE__ARRAY)
&& !(ic instanceof ClientMinPrincipalType)) {
logger.log(Level.FINE,
"Instead of ClientMinPrincipalType " + ic.getClass()
+ " object is returned");
throw new TestException("Instead of ClientMinPrincipalType "
+ ic.getClass() + " object is returned");
}
/*
* Verify that the argument passed to the constructor isn't modified.
* Compare argument for the constructor before and after invoking the
* constructor.
*/
// logger.log(Level.INFO, "Argument before invoking the constructor:");
// for (int i = 0; i < cl_copy.length; i++) {
// logger.log(Level.INFO, "cl_copy[" + i + "]:: " + cl_copy[i]);
// }
// logger.log(Level.INFO, "Argument after invoking the constructor :");
// for (int i = 0; i < cl.length; i++) {
// logger.log(Level.INFO, "cl[" + i + "]:: " + cl[i]);
// }
if (!Arrays.equals(cl, cl_copy)) {
logger.log(Level.FINE,
"The argument passed to the constructor is modified");
throw new TestException("The argument passed to the constructor"
+ " is modified");
}
logger.log(Level.FINE,
"The argument passed to the constructor isn't modified");
/*
* Verify that the argument passed to the constructor isn't retained;
* subsequent changes to that argument have no effect on the instance
* created. Compare set of all of the classes from the created
* object before and after changing the argument.
*/
Set icSet_before = null;
try {
Class icClass = ic.getClass();
Method elementsMethod = icClass.getMethod("elements", null);
// Get set of classes from the created constraint
icSet_before = (Set) elementsMethod.invoke(ic, null);
/*