for (int i = 0; i < cases.length; ++i) {
int testCase = cases[i];
logger.log(Level.INFO, "--> " + testCase);
MethodConstraints mc = null;
Permission[] perm = null;
if (testCase > 2000) {
perm = new Permission[] {
new RuntimePermission("getClassLoader")};
testCase -= 2000;
} else if (testCase > 1000) {
perm = new Permission[] {};
testCase -= 1000;
}
if (testCase > 200) {
mc = new FakeMethodConstraints(
new InvocationConstraint[] {Integrity.NO});
testCase -= 200;
} else if (testCase > 100) {
mc = new FakeMethodConstraints(null);
testCase -= 100;
}
boolean verify = false;
if (testCase > 10) {
verify = true;
testCase -= 10;
}
// a - same object
BasicProxyPreparer bpp = callConstructor(
testCase, verify, mc, perm);
if (!bpp.equals(bpp)) {
throw new TestException(
"equals method should return true (a)");
}
// b - eqaul object
bpp = callConstructor(
testCase, verify, mc, perm);
BasicProxyPreparer bpp2 = callConstructor(
testCase, verify, mc, perm);
if (!bpp.equals(bpp2)) {
throw new TestException(
"equals method should return true (b)");
}
// c - different class
bpp = callFakeConstructor(
testCase, verify, mc, perm);
BasicProxyPreparer fbpp = callConstructor(
testCase, verify, mc, perm);
if (bpp.equals(bpp2)) {
throw new TestException(
"equals method should return false (c)");
}
if (bpp2.equals(bpp)) {
throw new TestException(
"equals method should return false (c)");
}
if (testCase == 0) { continue; }
// d - not the same value for "verify"
bpp = callConstructor(
testCase, verify, mc, perm);
bpp2 = callConstructor(
testCase, !verify, mc, perm);
if (bpp.equals(bpp2)) {
throw new TestException(
"equals method should return false (d)");
}
if (bpp2.equals(bpp)) {
throw new TestException(
"equals method should return false (d)");
}
// g - permissions containing not the same elements
bpp = callConstructor(
testCase, verify, mc, perm);
Permission[] perm2 = new Permission[] {
new RuntimePermission("setClassLoader")};
bpp2 = callConstructor(
testCase, verify, mc, perm2);
if (bpp.equals(bpp2)) {
throw new TestException(
"equals method should return false (g)");
}
if (bpp2.equals(bpp)) {
throw new TestException(
"equals method should return false (g)");
}
// h - permissions containing the same elements, but in
// the another order
Permission[] perm3 = new Permission[] {
new RuntimePermission("getClassLoader"),
new RuntimePermission("setClassLoader")};
bpp = callConstructor(
testCase, verify, mc, perm3);
Permission[] perm4 = new Permission[] {
new RuntimePermission("setClassLoader"),
new RuntimePermission("getClassLoader")};
bpp2 = callConstructor(
testCase, verify, mc, perm4);
if (!bpp.equals(bpp2)) {
throw new TestException(
"equals method should return true (h)");
}
if (!bpp2.equals(bpp)) {
throw new TestException(
"equals method should return true (h)");
}
if (testCase == 2) { continue; }
// e, f - not equal method constraints
bpp = callConstructor(
testCase, verify, mc, perm);
MethodConstraints mc2 = new FakeMethodConstraints(
new InvocationConstraint[] {Integrity.YES});
bpp2 = callConstructor(
testCase, verify, mc2, perm);
if (bpp.equals(bpp2)) {
throw new TestException(