KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > clirr > core > internal > checks > MethodSetCheckTest


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.ScopeSelector;
6 import net.sf.clirr.core.internal.checks.MethodSetCheck;
7 import net.sf.clirr.core.internal.checks.AbstractCheckTestCase;
8 import net.sf.clirr.core.internal.checks.ExpectedDiff;
9
10 /**
11  * TODO: Docs.
12  *
13  * @author lkuehne
14  */

15 public class MethodSetCheckTest extends AbstractCheckTestCase
16 {
17     public void testMethodCheck() throws Exception JavaDoc
18     {
19         ExpectedDiff[] expected = new ExpectedDiff[] {
20
21             // method addition and removal
22
new ExpectedDiff("Method 'public void removedMethod(java.lang.String)' has been removed",
23                     Severity.ERROR, "testlib.MethodsChange", "public void removedMethod(java.lang.String)", null),
24             new ExpectedDiff("Accessibility of method 'public int getPriv2()' has been decreased from public to private",
25                     Severity.ERROR, "testlib.MethodsChange", "public int getPriv2()", null),
26             new ExpectedDiff("Method 'protected MethodsChange(int, boolean)' has been added",
27                     Severity.INFO, "testlib.MethodsChange", "protected MethodsChange(int, boolean)", null),
28             new ExpectedDiff("Method 'public java.lang.Long getPrivSquare()' has been added",
29                     Severity.INFO, "testlib.MethodsChange", "public java.lang.Long getPrivSquare()", null),
30
31             new ExpectedDiff("Method 'public void moveToSuper()' has been added",
32                     Severity.INFO, "testlib.ComplexMethodMoveBase", "public void moveToSuper()", null),
33             new ExpectedDiff("Method 'public void moveToSuper()' is now implemented in superclass testlib.ComplexMethodMoveBase",
34                     Severity.INFO, "testlib.ComplexMethodMoveSub", "public void moveToSuper()", null),
35
36             new ExpectedDiff("Method 'public void method()' has been removed, but an inherited definition exists.",
37                     Severity.INFO, "testlib.AbstractImpl", "public void method()", null),
38
39             // Constructor changes
40
new ExpectedDiff("Parameter 1 of 'protected MethodsChange(int)' has changed its type to java.lang.Integer",
41                     Severity.ERROR, "testlib.MethodsChange", "protected MethodsChange(int)", null),
42
43             // return type changes
44
new ExpectedDiff("Return type of method 'public java.lang.Number getPrivAsNumber()' has been changed to java.lang.Integer",
45                     Severity.ERROR, "testlib.MethodsChange", "public java.lang.Number getPrivAsNumber()", null),
46             // TODO: INFO if method is final
47
new ExpectedDiff("Return type of method 'public java.lang.Integer getPrivAsInteger()' has been changed to java.lang.Number",
48                     Severity.ERROR, "testlib.MethodsChange", "public java.lang.Integer getPrivAsInteger()", null),
49
50             // parameter list changes
51
// Note: This is the current behaviour, not necessarily the spec of the desired behaviour
52
// TODO: need to check assignability of types (and check if method or class is final?)
53
new ExpectedDiff("In method 'public void printPriv()' the number of arguments has changed",
54                     Severity.ERROR, "testlib.MethodsChange", "public void printPriv()", null),
55             new ExpectedDiff("Parameter 1 of 'public void strengthenParamType(java.lang.Object)' has changed its type to java.lang.String",
56                     Severity.ERROR, "testlib.MethodsChange", "public void strengthenParamType(java.lang.Object)", null),
57             new ExpectedDiff("Parameter 1 of 'public void weakenParamType(java.lang.String)' has changed its type to java.lang.Object",
58                     Severity.ERROR, "testlib.MethodsChange", "public void weakenParamType(java.lang.String)", null),
59             new ExpectedDiff("Parameter 1 of 'public void changeParamType(java.lang.String)' has changed its type to java.lang.Integer",
60                     Severity.ERROR, "testlib.MethodsChange", "public void changeParamType(java.lang.String)", null),
61
62             // deprecation changes
63
new ExpectedDiff("Method 'public void becomesDeprecated()' has been deprecated",
64                     Severity.INFO, "testlib.MethodsChange", "public void becomesDeprecated()", null),
65                     new ExpectedDiff("Method 'public void becomesUndeprecated()' is no longer deprecated",
66                             Severity.INFO, "testlib.MethodsChange", "public void becomesUndeprecated()", null),
67
68             // modifier changes
69
new ExpectedDiff("Method 'public void becomesFinal()' is now final",
70                     Severity.ERROR, "testlib.MethodsChange", "public void becomesFinal()", null),
71             new ExpectedDiff("Method 'public void becomesNonFinal()' is no longer final",
72                      Severity.INFO, "testlib.MethodsChange", "public void becomesNonFinal()", null),
73                     
74             // declared exceptions
75
// TODO
76
};
77         verify(expected);
78     }
79
80     protected final ClassChangeCheck createCheck(TestDiffListener tdl)
81     {
82         return new MethodSetCheck(tdl, new ScopeSelector());
83     }
84 }
85
Popular Tags