01: package net.sf.clirr.core.internal.checks;
02:
03: import net.sf.clirr.core.internal.ClassChangeCheck;
04: import net.sf.clirr.core.Severity;
05: import net.sf.clirr.core.ClassSelector;
06: import net.sf.clirr.core.ScopeSelector;
07: import net.sf.clirr.core.ClassFilter;
08: import net.sf.clirr.core.internal.checks.ClassScopeCheck;
09: import net.sf.clirr.core.internal.checks.AbstractCheckTestCase;
10: import net.sf.clirr.core.spi.Scope;
11:
12: /**
13: * Tests for the ClassScopeCheck test.
14: *
15: * @author Simon Kitching
16: */
17: public class ClassScopeCheckTest extends AbstractCheckTestCase {
18: public void testAccessChangesAreReported() throws Exception {
19: ExpectedDiff[] expected = new ExpectedDiff[] {
20: new ExpectedDiff(
21: "Decreased visibility of class from public to protected",
22: Severity.ERROR,
23: "testlib.scope.ClassScopeChange$A2", null, null),
24: new ExpectedDiff(
25: "Decreased visibility of class from public to package",
26: Severity.ERROR,
27: "testlib.scope.ClassScopeChange$A3", null, null),
28: new ExpectedDiff(
29: "Decreased visibility of class from public to private",
30: Severity.ERROR,
31: "testlib.scope.ClassScopeChange$A4", null, null),
32:
33: new ExpectedDiff(
34: "Increased visibility of class from protected to public",
35: Severity.INFO,
36: "testlib.scope.ClassScopeChange$B2", null, null),
37: new ExpectedDiff(
38: "Decreased visibility of class from protected to package",
39: Severity.ERROR,
40: "testlib.scope.ClassScopeChange$B3", null, null),
41: new ExpectedDiff(
42: "Decreased visibility of class from protected to private",
43: Severity.ERROR,
44: "testlib.scope.ClassScopeChange$B4", null, null),
45:
46: new ExpectedDiff(
47: "Increased visibility of class from package to public",
48: Severity.INFO,
49: "testlib.scope.ClassScopeChange$C2", null, null),
50: new ExpectedDiff(
51: "Increased visibility of class from package to protected",
52: Severity.INFO,
53: "testlib.scope.ClassScopeChange$C3", null, null),
54: // package->private is not an error, just an info, because we never report error for package or private diffs
55: new ExpectedDiff(
56: "Decreased visibility of class from package to private",
57: Severity.INFO,
58: "testlib.scope.ClassScopeChange$C4", null, null),
59:
60: new ExpectedDiff(
61: "Increased visibility of class from private to public",
62: Severity.INFO,
63: "testlib.scope.ClassScopeChange$D2", null, null),
64: new ExpectedDiff(
65: "Increased visibility of class from private to protected",
66: Severity.INFO,
67: "testlib.scope.ClassScopeChange$D3", null, null),
68: new ExpectedDiff(
69: "Increased visibility of class from private to package",
70: Severity.INFO,
71: "testlib.scope.ClassScopeChange$D4", null, null), };
72: verify(expected);
73: }
74:
75: protected ClassChangeCheck createCheck(TestDiffListener tdl) {
76: ScopeSelector scopeSelector = new ScopeSelector(Scope.PRIVATE);
77: return new ClassScopeCheck(tdl, scopeSelector);
78: }
79:
80: protected ClassFilter createClassSelector() {
81: // only check the testlib/scope/ClassScopeChange class.
82: ClassSelector classSelector = new ClassSelector(
83: ClassSelector.MODE_IF);
84: classSelector.addClass("testlib.scope.ClassScopeChange");
85: return classSelector;
86: }
87: }
|