1 package net.sf.clirr.core.internal.checks;
2
3 import net.sf.clirr.core.internal.ClassChangeCheck;
4 import net.sf.clirr.core.Severity;
5 import net.sf.clirr.core.ClassSelector;
6 import net.sf.clirr.core.ScopeSelector;
7 import net.sf.clirr.core.ClassFilter;
8 import net.sf.clirr.core.internal.checks.ClassScopeCheck;
9 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 {
19 public void testAccessChangesAreReported() throws Exception
20 {
21 ExpectedDiff[] expected = new ExpectedDiff[] {
22 new ExpectedDiff("Decreased visibility of class from public to protected", Severity.ERROR, "testlib.scope.ClassScopeChange$A2", null, null),
23 new ExpectedDiff("Decreased visibility of class from public to package", Severity.ERROR, "testlib.scope.ClassScopeChange$A3", null, null),
24 new ExpectedDiff("Decreased visibility of class from public to private", Severity.ERROR, "testlib.scope.ClassScopeChange$A4", null, null),
25
26 new ExpectedDiff("Increased visibility of class from protected to public", Severity.INFO, "testlib.scope.ClassScopeChange$B2", null, null),
27 new ExpectedDiff("Decreased visibility of class from protected to package", Severity.ERROR, "testlib.scope.ClassScopeChange$B3", null, null),
28 new ExpectedDiff("Decreased visibility of class from protected to private", Severity.ERROR, "testlib.scope.ClassScopeChange$B4", null, null),
29
30 new ExpectedDiff("Increased visibility of class from package to public", Severity.INFO, "testlib.scope.ClassScopeChange$C2", null, null),
31 new ExpectedDiff("Increased visibility of class from package to protected", Severity.INFO, "testlib.scope.ClassScopeChange$C3", null, null),
32
33 new ExpectedDiff("Decreased visibility of class from package to private", Severity.INFO, "testlib.scope.ClassScopeChange$C4", null, null),
34
35 new ExpectedDiff("Increased visibility of class from private to public", Severity.INFO, "testlib.scope.ClassScopeChange$D2", null, null),
36 new ExpectedDiff("Increased visibility of class from private to protected", Severity.INFO, "testlib.scope.ClassScopeChange$D3", null, null),
37 new ExpectedDiff("Increased visibility of class from private to package", Severity.INFO, "testlib.scope.ClassScopeChange$D4", null, null),
38 };
39 verify(expected);
40 }
41
42 protected ClassChangeCheck createCheck(TestDiffListener tdl)
43 {
44 ScopeSelector scopeSelector = new ScopeSelector(Scope.PRIVATE);
45 return new ClassScopeCheck(tdl, scopeSelector);
46 }
47
48 protected ClassFilter createClassSelector()
49 {
50
51 ClassSelector classSelector = new ClassSelector(ClassSelector.MODE_IF);
52 classSelector.addClass("testlib.scope.ClassScopeChange");
53 return classSelector;
54 }
55 }