logger.log(Level.FINE, "\tpref[" + i + "]:: " + pref[i]);
}
} else {
logger.log(Level.FINE, "\tpref:: null");
}
InvocationConstraints ic = null;
try {
ic = new InvocationConstraints(req, pref);
// If some Exception is expected
if (ex != null) {
logger.log(Level.FINE, "Expected Exception type:: " + ex);
throw new TestException("Instead of " + ex + " no Exception"
+ " has been thrown while invoking constructor "
+ tc.toString());
}
} catch (Exception e) {
logger.log(Level.FINE,
"Exception while invoking constructor " + tc.toString()
+ ":: " + e);
// If no Exception is expected
if (ex == null) {
throw new TestException("Exception while invoking constructor "
+ tc.toString(), 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 " + tc.toString());
} else {
return;
}
}
/*
* Verify that InvocationConstraints object is created.
*/
if (ic == null) {
logger.log(Level.FINE,
"InvocationConstraints object hasn't been created");
throw new TestException("InvocationConstraints object hasn't"
+ " been created");
}
logger.log(Level.FINE, "Returned object: " + ic.toString());
/*
* Verify that the first constraint, req, is added as a requirement
* if it is a non-null value.
*/
Set reqs = ic.requirements();
if (req == null) {
if (!reqs.isEmpty()) {
String s = "Expected that no requirement has been added when"
+ " req is null; Really requirements aren't empty";
logger.log(Level.FINE, s);
throw new TestException(s);
}
} else {
for (int i = 0; i < req.length; i++) {
if (!reqs.contains(req[i])) {
String s = "Expected that requirement has been added when"
+ " req is non-null; Really requirements doesn't"
+ " contain the specified req";
logger.log(Level.FINE, s);
throw new TestException(s);
}
}
}
/*
* Verify that the second constraint, pref, is added as a preference
* if it is a non-null value.
*/
Set prefs = ic.preferences();
if (pref == null) {
if (!prefs.isEmpty()) {
String s = "Expected that no preference has been added"
+ " when pref is null;"