01: package net.sf.clirr.core.internal.checks;
02:
03: import net.sf.clirr.core.Severity;
04: import net.sf.clirr.core.ScopeSelector;
05: import net.sf.clirr.core.internal.ClassChangeCheck;
06: import net.sf.clirr.core.internal.checks.FieldSetCheck;
07: import net.sf.clirr.core.internal.checks.AbstractCheckTestCase;
08: import net.sf.clirr.core.internal.checks.ExpectedDiff;
09:
10: /**
11: * Tests FieldSetCheck.
12: *
13: * @author lkuehne
14: */
15: public class FieldSetCheckTest extends AbstractCheckTestCase {
16: public void testFieldCheck() throws Exception {
17: ExpectedDiff[] expected = new ExpectedDiff[] {
18: new ExpectedDiff("Removed field stat7", Severity.ERROR,
19: "testlib.MembersChange", null, "stat7"),
20: new ExpectedDiff(
21: "Accessibility of field fin2 has been weakened from public to protected",
22: Severity.ERROR, "testlib.MembersChange", null,
23: "fin2"),
24: new ExpectedDiff(
25: "Accessibility of field stat4 has been weakened from public to protected",
26: Severity.ERROR, "testlib.MembersChange", null,
27: "stat4"),
28: new ExpectedDiff(
29: "Accessibility of field priv2 has been increased from private to public",
30: Severity.INFO, "testlib.MembersChange", null,
31: "priv2"),
32: new ExpectedDiff(
33: "Accessibility of field stat5 has been weakened from public to private",
34: Severity.ERROR, "testlib.MembersChange", null,
35: "stat5"),
36: new ExpectedDiff("Field stat2 is now final",
37: Severity.ERROR, "testlib.MembersChange", null,
38: "stat2"),
39: new ExpectedDiff("Field pub3 is now final",
40: Severity.ERROR, "testlib.MembersChange", null,
41: "pub3"),
42: new ExpectedDiff(
43: "Accessibility of field stat6 has been weakened from public to package",
44: Severity.ERROR, "testlib.MembersChange", null,
45: "stat6"),
46: new ExpectedDiff("Field stat3 is now non-static",
47: Severity.ERROR, "testlib.MembersChange", null,
48: "stat3"),
49: new ExpectedDiff("Field fin3 is now non-static",
50: Severity.ERROR, "testlib.MembersChange", null,
51: "fin3"),
52: new ExpectedDiff("Added public field stat8",
53: Severity.INFO, "testlib.MembersChange", null,
54: "stat8"),
55: new ExpectedDiff("Field fin4 is now non-final",
56: Severity.INFO, "testlib.MembersChange", null,
57: "fin4"),
58: new ExpectedDiff("Field pub2 is now static",
59: Severity.ERROR, "testlib.MembersChange", null,
60: "pub2"),
61: new ExpectedDiff(
62: "Changed type of field obj1 from java.lang.Object to java.lang.String",
63: Severity.ERROR, "testlib.MembersChange", null,
64: "obj1"),
65: new ExpectedDiff(
66: "Changed type of field obj2 from java.lang.Boolean to java.lang.String",
67: Severity.ERROR, "testlib.MembersChange", null,
68: "obj2"),
69: new ExpectedDiff(
70: "Value of field fin6 is no longer a compile-time constant",
71: Severity.WARNING, "testlib.MembersChange",
72: null, "fin6"),
73: new ExpectedDiff(
74: "Value of compile-time constant fin5 has been changed",
75: Severity.WARNING, "testlib.MembersChange",
76: null, "fin5"),
77: new ExpectedDiff("Removed field pub5", Severity.ERROR,
78: "testlib.MembersChange", null, "pub5"),
79: new ExpectedDiff(
80: "Field fin7 has been removed, but it was previously a constant",
81: Severity.WARNING, Severity.ERROR,
82: "testlib.MembersChange", null, "fin7"), };
83: verify(expected);
84: }
85:
86: protected final ClassChangeCheck createCheck(TestDiffListener tdl) {
87: ScopeSelector scopeSelector = new ScopeSelector();
88: return new FieldSetCheck(tdl, scopeSelector);
89: }
90:
91: }
|