|| 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);
/*
* Change argument passed to the constructor while creating
* the constraint
*/
for (int i = 0; i < cl.length; i++) {
cl[i] = Exception.class;
}
// Get set of classes from the created constraint
Set icSet_after = (Set) elementsMethod.invoke(ic, null);
// logger.log(Level.INFO, "Set of all of the classes of created object"
// + " before modification of arg passed to the constructor: "
// + icSet_before);
// logger.log(Level.INFO, "Set of all of the classes of created object"
// + " after modification of arg passed to the constructor : "
// + icSet_after);
if (!icSet_after.equals(icSet_before)) {
logger.log(Level.FINE,
"The argument passed to the constructor is retained");
throw new TestException("The argument passed to the"
+ " constructor is retained");
}
} catch (Exception e) {
logger.log(Level.FINE,
"Exception is thrown while invoking elements() method using"
+ " reflection: " + e);
throw new TestException("Exception is thrown while invoking"
+ " elements() method using reflection.", e);
}
logger.log(Level.FINE,
"The argument passed to the constructor isn't retained");