logger.log(Level.INFO, "======================================");
// 1
String name = "someMethod";
InvocationConstraint ic = Delegation.YES;
InvocationConstraints constraints = new InvocationConstraints(
ic, null);
MethodDesc methodDesc1 = new MethodDesc(name, constraints);
MethodDesc methodDesc2 = new MethodDesc(constraints);
MethodDesc [] descs = {methodDesc1, methodDesc2};
new BasicMethodConstraints(descs);
// 2
MethodDesc [] storedDescs = {methodDesc1, methodDesc2};
MethodDesc [] passedDescs = {methodDesc1, methodDesc2};
new BasicMethodConstraints(passedDescs);
for (int j = 0; j < passedDescs.length; ++j) {
if (storedDescs[j] != passedDescs[j]) {
throw new TestException(
"MethodDesc array was modified");
}
}
// 3
String name2 = "*someMethod";
MethodDesc methodDesc3 = new MethodDesc(name2, constraints);
MethodDesc [] descs1 = {methodDesc1, methodDesc2};
MethodDesc [] descs2 = {methodDesc1, methodDesc2};
BasicMethodConstraints bmc1 = new BasicMethodConstraints(descs1);
BasicMethodConstraints bmc2 = new BasicMethodConstraints(descs2);
descs2[1] = methodDesc3;
if (!bmc1.equals(bmc2)) {
throw new TestException(
"BasicMethodConstraints objects should be equal");
}
// 4
try {
new BasicMethodConstraints((MethodDesc []) null);
throw new TestException(
"NullPointerException should be thrown");
} catch (NullPointerException ignore) {
}
// 5
try {
MethodDesc [] descs1null = {null, methodDesc2};
new BasicMethodConstraints(descs1null);
throw new TestException(
"NullPointerException should be thrown");
} catch (NullPointerException ignore) {
}
try {
MethodDesc [] descs2null = {methodDesc1, null};
new BasicMethodConstraints(descs2null);
throw new TestException(
"NullPointerException should be thrown");
} catch (NullPointerException ignore) {
}
// 6
try {
MethodDesc [] emptyDescs = {};
new BasicMethodConstraints(emptyDescs);
throw new TestException(
"IllegalArgumentException should be thrown");
} catch (IllegalArgumentException ignore) {
}
// 7
try {
MethodDesc [] invalidDescs = {methodDesc2, methodDesc1};
new BasicMethodConstraints(invalidDescs);
throw new TestException(
"IllegalArgumentException should be thrown");
} catch (IllegalArgumentException ignore) {
}
// 8
new BasicMethodConstraints(constraints);
// 9
InvocationConstraints emptyConstraints = new InvocationConstraints(
(InvocationConstraint) null, null);
bmc1 = new BasicMethodConstraints(emptyConstraints);
bmc2 = new BasicMethodConstraints((InvocationConstraints) null);
if (!bmc1.equals(bmc2)) {
throw new TestException(