diff options
-rw-r--r-- | build.gradle | 12 | ||||
-rw-r--r-- | src/com/google/doclava/ClassInfo.java | 47 | ||||
-rw-r--r-- | src/com/google/doclava/Doclava.java | 2 | ||||
-rw-r--r-- | src/com/google/doclava/Errors.java | 84 | ||||
-rw-r--r-- | src/com/google/doclava/FieldInfo.java | 21 | ||||
-rw-r--r-- | src/com/google/doclava/MethodInfo.java | 11 | ||||
-rw-r--r-- | src/com/google/doclava/PackageInfo.java | 9 | ||||
-rw-r--r-- | src/com/google/doclava/apicheck/ApiCheck.java | 16 | ||||
-rw-r--r-- | test/api/added-class.xml (renamed from test/api/add-class.xml) | 0 | ||||
-rw-r--r-- | test/api/added-deprecated-class.xml | 132 | ||||
-rw-r--r-- | test/api/added-deprecated-field.xml | 289 | ||||
-rw-r--r-- | test/api/added-deprecated-method.xml | 289 | ||||
-rw-r--r-- | test/api/added-method.xml | 289 | ||||
-rw-r--r-- | test/doclava/ApiCheckTest.java | 140 |
14 files changed, 1252 insertions, 89 deletions
diff --git a/build.gradle b/build.gradle index de34436..16cc795 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,10 @@ apply plugin: 'java' import javax.tools.ToolProvider +dependencies { + testCompile 'junit:junit:4.12' +} + sourceSets { main { java { @@ -11,6 +15,14 @@ sourceSets { srcDirs = ['res/'] } } + test { + java { + srcDirs = ['test/'] + } + resources { + srcDirs = ['test/api'] + } + } } dependencies { diff --git a/src/com/google/doclava/ClassInfo.java b/src/com/google/doclava/ClassInfo.java index 7b50938..b37da69 100644 --- a/src/com/google/doclava/ClassInfo.java +++ b/src/com/google/doclava/ClassInfo.java @@ -569,9 +569,16 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco } } - if (commentDeprecated != annotationDeprecated) { + // Check to see that the JavaDoc contains @deprecated AND the method is marked as @Deprecated. + // Otherwise, warn. + // Note: We only do this for "included" classes (i.e. those we have source code for); we do + // not have comments for classes from .class files but we do know whether a class is marked + // as @Deprecated. + if (isIncluded() && commentDeprecated != annotationDeprecated) { Errors.error(Errors.DEPRECATION_MISMATCH, position(), "Class " + qualifiedName() - + ": @Deprecated annotation and @deprecated comment do not match"); + + ": @Deprecated annotation (" + (annotationDeprecated ? "" : "not ") + + "present) and @deprecated doc tag (" + (commentDeprecated ? "" : "not ") + + "present) do not match"); } mIsDeprecated = commentDeprecated | annotationDeprecated; @@ -2099,8 +2106,13 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco mi = ClassInfo.interfaceMethod(mInfo, cl); } if (mi == null) { - Errors.error(Errors.REMOVED_METHOD, mInfo.position(), "Removed public method " - + mInfo.prettyQualifiedSignature()); + if (mInfo.isDeprecated()) { + Errors.error(Errors.REMOVED_DEPRECATED_METHOD, mInfo.position(), + "Removed deprecated public method " + mInfo.prettyQualifiedSignature()); + } else { + Errors.error(Errors.REMOVED_METHOD, mInfo.position(), + "Removed public method " + mInfo.prettyQualifiedSignature()); + } consistent = false; } } @@ -2135,8 +2147,13 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco consistent = false; } } else { - Errors.error(Errors.REMOVED_METHOD, mInfo.position(), "Removed public constructor " - + mInfo.prettyQualifiedSignature()); + if (mInfo.isDeprecated()) { + Errors.error(Errors.REMOVED_DEPRECATED_METHOD, mInfo.position(), + "Removed deprecated public constructor " + mInfo.prettyQualifiedSignature()); + } else { + Errors.error(Errors.REMOVED_METHOD, mInfo.position(), + "Removed public constructor " + mInfo.prettyQualifiedSignature()); + } consistent = false; } } @@ -2160,8 +2177,13 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco consistent = false; } } else { - Errors.error(Errors.REMOVED_FIELD, mInfo.position(), "Removed field " - + mInfo.qualifiedName()); + if (mInfo.isDeprecated()) { + Errors.error(Errors.REMOVED_DEPRECATED_FIELD, mInfo.position(), + "Removed deprecated field " + mInfo.qualifiedName()); + } else { + Errors.error(Errors.REMOVED_FIELD, mInfo.position(), + "Removed field " + mInfo.qualifiedName()); + } consistent = false; } } @@ -2179,8 +2201,13 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco consistent = false; } } else { - Errors.error(Errors.REMOVED_FIELD, info.position(), "Removed enum constant " - + info.qualifiedName()); + if (info.isDeprecated()) { + Errors.error(Errors.REMOVED_DEPRECATED_FIELD, info.position(), + "Removed deprecated enum constant " + info.qualifiedName()); + } else { + Errors.error(Errors.REMOVED_FIELD, info.position(), + "Removed enum constant " + info.qualifiedName()); + } consistent = false; } } diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java index 243d51f..a43ca62 100644 --- a/src/com/google/doclava/Doclava.java +++ b/src/com/google/doclava/Doclava.java @@ -968,7 +968,7 @@ public class Doclava { ResourceLoader loader = new FileSystemResourceLoader(f); JSilver js = new JSilver(loader); - writeDirectory(f, outputPathResourcesDir + "resources/", js); + writeDirectory(f, outputPathResourcesDir, js); } catch(Exception e) { System.err.println("Could not copy resourcesdir: " + e); } diff --git a/src/com/google/doclava/Errors.java b/src/com/google/doclava/Errors.java index 156de66..bc9a77b 100644 --- a/src/com/google/doclava/Errors.java +++ b/src/com/google/doclava/Errors.java @@ -54,11 +54,11 @@ public class Errors { } public static void error(Error error, SourcePositionInfo where, String text) { - if (error.level == HIDDEN) { + if (error.getLevel() == HIDDEN) { return; } - int level = (!warningsAreErrors && error.level == WARNING) ? WARNING : ERROR; + int level = (!warningsAreErrors && error.getLevel() == WARNING) ? WARNING : ERROR; String which = level == WARNING ? " warning " : " error "; String message = which + error.code + ": " + text; @@ -68,7 +68,7 @@ public class Errors { allErrors.add(new ErrorMessage(error, where, message)); - if (error.level == ERROR || (warningsAreErrors && error.level == WARNING)) { + if (error.getLevel() == ERROR || (warningsAreErrors && error.getLevel() == WARNING)) { hadError = true; } } @@ -84,12 +84,12 @@ public class Errors { public static void printErrors(Set<ErrorMessage> errors) { for (ErrorMessage m : errors) { - if (m.error.level == WARNING) { + if (m.error.getLevel() == WARNING) { System.err.println(m.toString()); } } for (ErrorMessage m : errors) { - if (m.error.level == ERROR) { + if (m.error.getLevel() == ERROR) { System.err.println(m.toString()); } } @@ -99,6 +99,7 @@ public class Errors { return allErrors; } + public static int INHERIT = -1; public static int HIDDEN = 0; public static int WARNING = 1; public static int ERROR = 2; @@ -109,13 +110,71 @@ public class Errors { public static class Error { public int code; + + /** + * @deprecated This field should not be access directly. Instead, use + * {@link #getLevel()}. + */ + @Deprecated public int level; + /** + * When {@code level} is set to {@link #INHERIT}, this is the parent from + * which the error will inherit its level. + */ + private final Error parent; + public Error(int code, int level) { this.code = code; this.level = level; + this.parent = null; } - + + public Error(int code, Error parent) { + this.code = code; + this.level = -1; + this.parent = parent; + } + + /** + * Returns the implied level for this error. + * <p> + * If the level is {@link #INHERIT}, the level will be returned for the + * parent. + * + * @return + * @throws IllegalStateException if the level is {@link #INHERIT} and the + * parent is {@code null} + */ + public int getLevel() { + if (level == INHERIT) { + if (parent == null) { + throw new IllegalStateException("Error with level INHERIT must have non-null parent"); + } + return parent.getLevel(); + } + return level; + } + + /** + * Sets the level. + * <p> + * Valid arguments are: + * <ul> + * <li>{@link #HIDDEN} + * <li>{@link #WARNING} + * <li>{@link #ERROR} + * </ul> + * + * @param level the level to set + */ + public void setLevel(int level) { + if (level == INHERIT) { + throw new IllegalArgumentException("Error level may not be set to INHERIT"); + } + this.level = level; + } + public String toString() { return "Error #" + this.code; } @@ -149,6 +208,9 @@ public class Errors { public static Error CHANGED_SYNCHRONIZED = new Error(25, ERROR); public static Error ADDED_FINAL_UNINSTANTIABLE = new Error(26, WARNING); public static Error REMOVED_FINAL = new Error(27, WARNING); + public static Error REMOVED_DEPRECATED_CLASS = new Error(28, REMOVED_CLASS); + public static Error REMOVED_DEPRECATED_METHOD = new Error(29, REMOVED_METHOD); + public static Error REMOVED_DEPRECATED_FIELD = new Error(30, REMOVED_FIELD); // Errors in javadoc generation public static final Error UNRESOLVED_LINK = new Error(101, WARNING); @@ -174,8 +236,8 @@ public class Errors { public static final Error HIDDEN_TYPE_PARAMETER = new Error(121, HIDDEN); public static final Error PRIVATE_SUPERCLASS = new Error(122, ERROR); - public static final Error[] ERRORS = - {UNRESOLVED_LINK, BAD_INCLUDE_TAG, UNKNOWN_TAG, UNKNOWN_PARAM_TAG_NAME, + public static final Error[] ERRORS = { + UNRESOLVED_LINK, BAD_INCLUDE_TAG, UNKNOWN_TAG, UNKNOWN_PARAM_TAG_NAME, UNDOCUMENTED_PARAMETER, BAD_ATTR_TAG, BAD_INHERITDOC, HIDDEN_LINK, HIDDEN_CONSTRUCTOR, UNAVAILABLE_SYMBOL, HIDDEN_SUPERCLASS, DEPRECATED, DEPRECATION_MISMATCH, MISSING_COMMENT, IO_ERROR, NO_SINCE_DATA, NO_FEDERATION_DATA, PARSE_ERROR, ADDED_PACKAGE, ADDED_CLASS, @@ -184,12 +246,14 @@ public class Errors { CHANGED_TRANSIENT, CHANGED_VOLATILE, CHANGED_TYPE, CHANGED_VALUE, CHANGED_SUPERCLASS, CHANGED_SCOPE, CHANGED_ABSTRACT, CHANGED_THROWS, CHANGED_NATIVE, CHANGED_CLASS, CHANGED_DEPRECATED, CHANGED_SYNCHRONIZED, ADDED_FINAL_UNINSTANTIABLE, REMOVED_FINAL, - BROKEN_SINCE_FILE, INVALID_CONTENT_TYPE, HIDDEN_TYPE_PARAMETER, PRIVATE_SUPERCLASS}; + REMOVED_DEPRECATED_CLASS, REMOVED_DEPRECATED_METHOD, REMOVED_DEPRECATED_FIELD, + BROKEN_SINCE_FILE, INVALID_CONTENT_TYPE, HIDDEN_TYPE_PARAMETER, PRIVATE_SUPERCLASS + }; public static boolean setErrorLevel(int code, int level) { for (Error e : ERRORS) { if (e.code == code) { - e.level = level; + e.setLevel(level); return true; } } diff --git a/src/com/google/doclava/FieldInfo.java b/src/com/google/doclava/FieldInfo.java index 83d748a..85c1a85 100644 --- a/src/com/google/doclava/FieldInfo.java +++ b/src/com/google/doclava/FieldInfo.java @@ -53,7 +53,7 @@ public class FieldInfo extends MemberInfo { { return isConstant(isFinal, isStatic, constantValue) ? "constant" : "field"; } - + public String qualifiedName() { String parentQName = (containingClass() != null) ? (containingClass().qualifiedName() + ".") : ""; @@ -101,7 +101,7 @@ public class FieldInfo extends MemberInfo { mDeprecatedKnown = true; mIsDeprecated = deprecated; } - + public boolean isDeprecated() { if (!mDeprecatedKnown) { boolean commentDeprecated = comment().isDeprecated(); @@ -113,10 +113,17 @@ public class FieldInfo extends MemberInfo { } } - if (commentDeprecated != annotationDeprecated) { + // Check to see that the JavaDoc contains @deprecated AND the method is marked as @Deprecated. + // Otherwise, warn. + // Note: We only do this for "included" classes (i.e. those we have source code for); we do + // not have comments for classes from .class files but we do know whether a field is marked + // as @Deprecated. + if (mContainingClass.isIncluded() && commentDeprecated != annotationDeprecated) { Errors.error(Errors.DEPRECATION_MISMATCH, position(), "Field " + mContainingClass.qualifiedName() + "." + name() - + ": @Deprecated annotation and @deprecated comment do not match"); + + ": @Deprecated annotation (" + (annotationDeprecated ? "" : "not ") + + "present) and @deprecated doc tag (" + (commentDeprecated ? "" : "not ") + + "present) do not match"); } mIsDeprecated = commentDeprecated | annotationDeprecated; @@ -402,14 +409,14 @@ public class FieldInfo extends MemberInfo { public boolean isVolatile() { return mIsVolatile; } - + // Check the declared value with a typed comparison, not a string comparison, // to accommodate toolchains with different fp -> string conversions. private boolean valueEquals(FieldInfo other) { if ((mConstantValue == null) != (other.mConstantValue == null)) { return false; } - + // Null values are considered equal if (mConstantValue == null) { return true; @@ -418,7 +425,7 @@ public class FieldInfo extends MemberInfo { return mType.equals(other.mType) && mConstantValue.equals(other.mConstantValue); } - + public boolean isConsistent(FieldInfo fInfo) { boolean consistent = true; if (!mType.equals(fInfo.mType)) { diff --git a/src/com/google/doclava/MethodInfo.java b/src/com/google/doclava/MethodInfo.java index 28f1899..f45dff4 100644 --- a/src/com/google/doclava/MethodInfo.java +++ b/src/com/google/doclava/MethodInfo.java @@ -216,10 +216,17 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv } } - if (commentDeprecated != annotationDeprecated) { + // Check to see that the JavaDoc contains @deprecated AND the method is marked as @Deprecated. + // Otherwise, warn. + // Note: We only do this for "included" classes (i.e. those we have source code for); we do + // not have comments for classes from .class files but we do know whether a method is marked + // as @Deprecated. + if (mContainingClass.isIncluded() && commentDeprecated != annotationDeprecated) { Errors.error(Errors.DEPRECATION_MISMATCH, position(), "Method " + mContainingClass.qualifiedName() + "." + name() - + ": @Deprecated annotation and @deprecated doc tag do not match"); + + ": @Deprecated annotation (" + (annotationDeprecated ? "" : "not ") + + "present) and @deprecated doc tag (" + (commentDeprecated ? "" : "not ") + + "present) do not match"); } mIsDeprecated = commentDeprecated | annotationDeprecated; diff --git a/src/com/google/doclava/PackageInfo.java b/src/com/google/doclava/PackageInfo.java index 46b5b8f..2cdfe4a 100644 --- a/src/com/google/doclava/PackageInfo.java +++ b/src/com/google/doclava/PackageInfo.java @@ -498,8 +498,13 @@ public class PackageInfo extends DocInfo implements ContainerInfo { clsInfoDiff.add(deltaClsInfo); } } else { - Errors.error(Errors.REMOVED_CLASS, cInfo.position(), "Removed public class " - + cInfo.qualifiedName()); + if (cInfo.isDeprecated()) { + Errors.error(Errors.REMOVED_DEPRECATED_CLASS, cInfo.position(), + "Removed deprecated public class " + cInfo.qualifiedName()); + } else { + Errors.error(Errors.REMOVED_CLASS, cInfo.position(), + "Removed public class " + cInfo.qualifiedName()); + } consistent = false; } } diff --git a/src/com/google/doclava/apicheck/ApiCheck.java b/src/com/google/doclava/apicheck/ApiCheck.java index d9e8a01..8498d0a 100644 --- a/src/com/google/doclava/apicheck/ApiCheck.java +++ b/src/com/google/doclava/apicheck/ApiCheck.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.List; import java.util.HashSet; import java.util.Set; -import java.util.Stack; import com.google.doclava.Errors; import com.google.doclava.PackageInfo; @@ -126,16 +125,19 @@ public class ApiCheck { ApiInfo oldApi; ApiInfo newApi; - ApiInfo oldRemovedApi; - ApiInfo newRemovedApi; + ApiInfo oldRemovedApi = null; + ApiInfo newRemovedApi = null; // commandline options look like: - // [other optoins] old_api.txt new_api.txt old_removed_api.txt new_removed_api.txt + // [other options] old_api.txt new_api.txt + // [other options] old_api.txt new_api.txt old_removed_api.txt new_removed_api.txt try { oldApi = parseApi(args.get(0)); newApi = parseApi(args.get(1)); - oldRemovedApi = parseApi(args.get(2)); - newRemovedApi = parseApi(args.get(3)); + if (args.size() > 2) { + oldRemovedApi = parseApi(args.get(2)); + newRemovedApi = parseApi(args.get(3)); + } } catch (ApiParseException e) { e.printStackTrace(); System.err.println("Error parsing API"); @@ -147,7 +149,7 @@ public class ApiCheck { oldApi.isConsistent(newApi, null, ignoredPackages, ignoredClasses); } - if (!Errors.hadError) { + if (oldRemovedApi != null && !Errors.hadError) { oldRemovedApi.isConsistent(newRemovedApi, null, ignoredPackages, ignoredClasses); } diff --git a/test/api/add-class.xml b/test/api/added-class.xml index 4795229..4795229 100644 --- a/test/api/add-class.xml +++ b/test/api/added-class.xml diff --git a/test/api/added-deprecated-class.xml b/test/api/added-deprecated-class.xml new file mode 100644 index 0000000..b2b9d23 --- /dev/null +++ b/test/api/added-deprecated-class.xml @@ -0,0 +1,132 @@ +<api> +<package name="doclava.sample" +> +<class name="Bunk" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Bunk" + type="doclava.sample.Bunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +<method name="sunk" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="DeBunk" + extends="doclava.sample.Bunk" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="DeBunk" + type="doclava.sample.DeBunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +</class> +<class name="Foo" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Foo" + type="doclava.sample.Foo" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get1" + return="int" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="nothing" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Funk" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="deprecated" + visibility="public" +> +<constructor name="Funk" + type="doclava.sample.Funk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +</class> +</package> +</api> diff --git a/test/api/added-deprecated-field.xml b/test/api/added-deprecated-field.xml new file mode 100644 index 0000000..06744a7 --- /dev/null +++ b/test/api/added-deprecated-field.xml @@ -0,0 +1,289 @@ +<api> +<package name="doclava.sample" +> +<class name="Abstract" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Abstract" + type="doclava.sample.Abstract" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="me" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="run" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Bunk" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Bunk" + type="doclava.sample.Bunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +<method name="sunk" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="DeBunk" + extends="doclava.sample.Bunk" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="DeBunk" + type="doclava.sample.DeBunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +</class> +<class name="Extender" + extends="doclava.sample.Abstract" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="doclava.sample.Face"> +</implements> +<constructor name="Extender" + type="doclava.sample.Extender" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="returnObject" + return="java.lang.Object" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="o" type="java.lang.Object"> +</parameter> +</method> +<method name="run" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<field name="RAW_DEAL" + type="java.lang.String" + transient="false" + volatile="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="TREE_FITTY" + type="double" + transient="false" + volatile="false" + value="3.50001" + static="false" + final="true" + deprecated="not deprecated" + visibility="protected" +> +</field> +<field name="FOUR_FITTY" + type="double" + transient="false" + volatile="false" + value="4.50001" + static="false" + final="true" + deprecated="deprecated" + visibility="public" +> +</field> +</class> +<interface name="Face" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="returnObject" + return="java.lang.Object" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="o" type="java.lang.Object"> +</parameter> +</method> +</interface> +<class name="Foo" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Foo" + type="doclava.sample.Foo" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get1" + return="int" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="nothing" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Small" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Small" + type="doclava.sample.Small" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get" + return="doclava.sample.Small" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<field name="SEVENTEEN" + type="int" + transient="false" + volatile="false" + value="17" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +</class> +</package> +</api> diff --git a/test/api/added-deprecated-method.xml b/test/api/added-deprecated-method.xml new file mode 100644 index 0000000..85df51b --- /dev/null +++ b/test/api/added-deprecated-method.xml @@ -0,0 +1,289 @@ +<api> +<package name="doclava.sample" +> +<class name="Abstract" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Abstract" + type="doclava.sample.Abstract" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="me" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="run" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Bunk" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Bunk" + type="doclava.sample.Bunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +<method name="sunk" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="DeBunk" + extends="doclava.sample.Bunk" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="DeBunk" + type="doclava.sample.DeBunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +</class> +<class name="Extender" + extends="doclava.sample.Abstract" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="doclava.sample.Face"> +</implements> +<constructor name="Extender" + type="doclava.sample.Extender" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="returnObject" + return="java.lang.Object" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="o" type="java.lang.Object"> +</parameter> +</method> +<method name="run" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="dmc" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="deprecated" + visibility="public" +> +</method> +<field name="RAW_DEAL" + type="java.lang.String" + transient="false" + volatile="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="TREE_FITTY" + type="double" + transient="false" + volatile="false" + value="3.50001" + static="false" + final="true" + deprecated="not deprecated" + visibility="protected" +> +</field> +</class> +<interface name="Face" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="returnObject" + return="java.lang.Object" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="o" type="java.lang.Object"> +</parameter> +</method> +</interface> +<class name="Foo" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Foo" + type="doclava.sample.Foo" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get1" + return="int" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="nothing" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Small" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Small" + type="doclava.sample.Small" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get" + return="doclava.sample.Small" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<field name="SEVENTEEN" + type="int" + transient="false" + volatile="false" + value="17" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +</class> +</package> +</api> diff --git a/test/api/added-method.xml b/test/api/added-method.xml new file mode 100644 index 0000000..2281f29 --- /dev/null +++ b/test/api/added-method.xml @@ -0,0 +1,289 @@ +<api> +<package name="doclava.sample" +> +<class name="Abstract" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Abstract" + type="doclava.sample.Abstract" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="me" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="run" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Bunk" + extends="java.lang.Object" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Bunk" + type="doclava.sample.Bunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +<method name="sunk" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="DeBunk" + extends="doclava.sample.Bunk" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="DeBunk" + type="doclava.sample.DeBunk" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="gunk" + return="java.lang.Integer" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="args" type="int..."> +</parameter> +</method> +</class> +<class name="Extender" + extends="doclava.sample.Abstract" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="doclava.sample.Face"> +</implements> +<constructor name="Extender" + type="doclava.sample.Extender" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="returnObject" + return="java.lang.Object" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="o" type="java.lang.Object"> +</parameter> +</method> +<method name="run" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="dmc" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<field name="RAW_DEAL" + type="java.lang.String" + transient="false" + volatile="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="TREE_FITTY" + type="double" + transient="false" + volatile="false" + value="3.50001" + static="false" + final="true" + deprecated="not deprecated" + visibility="protected" +> +</field> +</class> +<interface name="Face" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="returnObject" + return="java.lang.Object" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="o" type="java.lang.Object"> +</parameter> +</method> +</interface> +<class name="Foo" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Foo" + type="doclava.sample.Foo" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get1" + return="int" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="nothing" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> +<class name="Small" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="Small" + type="doclava.sample.Small" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<method name="get" + return="doclava.sample.Small" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<field name="SEVENTEEN" + type="int" + transient="false" + volatile="false" + value="17" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +</class> +</package> +</api> diff --git a/test/doclava/ApiCheckTest.java b/test/doclava/ApiCheckTest.java index c3393a1..536fbf5 100644 --- a/test/doclava/ApiCheckTest.java +++ b/test/doclava/ApiCheckTest.java @@ -36,14 +36,14 @@ public class ApiCheckTest extends TestCase { Errors.setErrorLevel(error.code, Errors.ERROR); } } - + public void testEquivalentApi() { String[] args = { "test/api/medium.xml", "test/api/medium.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(report.errors().size(), 0); } - + public void testMethodReturnTypeChanged() { String[] args = { "test/api/return-type-changed-1.xml", "test/api/return-type-changed-2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -51,13 +51,13 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_TYPE, report.errors().iterator().next().error()); } - + public void testMethodParameterChanged() { String[] args = { "test/api/parameter-changed-1.xml", "test/api/parameter-changed-2.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(2, report.errors().size()); - + Iterator<ErrorMessage> errors = report.errors().iterator(); ErrorMessage m1 = errors.next(); ErrorMessage m2 = errors.next(); @@ -65,7 +65,7 @@ public class ApiCheckTest extends TestCase { assertTrue(m1.error().equals(Errors.ADDED_METHOD) || m1.error().equals(Errors.REMOVED_METHOD)); assertTrue(m2.error().equals(Errors.ADDED_METHOD) || m2.error().equals(Errors.REMOVED_METHOD)); } - + public void testConstructorParameterChanged() { String[] args = { "test/api/parameter-changed-1.xml", "test/api/parameter-changed-3.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -78,23 +78,31 @@ public class ApiCheckTest extends TestCase { assertTrue(m1.error().equals(Errors.ADDED_METHOD) || m1.error().equals(Errors.REMOVED_METHOD)); assertTrue(m2.error().equals(Errors.ADDED_METHOD) || m2.error().equals(Errors.REMOVED_METHOD)); } - + public void testAddedClass() { - String[] args = { "test/api/simple.xml", "test/api/add-class.xml" }; + String[] args = { "test/api/simple.xml", "test/api/added-class.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(1, report.errors().size()); assertEquals(Errors.ADDED_CLASS, report.errors().iterator().next().error()); } - + public void testRemovedClass() { - String[] args = { "test/api/add-class.xml", "test/api/simple.xml" }; + String[] args = { "test/api/added-class.xml", "test/api/simple.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(1, report.errors().size()); assertEquals(Errors.REMOVED_CLASS, report.errors().iterator().next().error()); } - + + public void testRemovedDeprecatedClass() { + String[] args = { "test/api/added-deprecated-class.xml", "test/api/simple.xml" }; + ApiCheck apiCheck = new ApiCheck(); + Report report = apiCheck.checkApi(args); + assertEquals(1, report.errors().size()); + assertEquals(Errors.REMOVED_DEPRECATED_CLASS, report.errors().iterator().next().error()); + } + public void testChangedSuper() { String[] args = { "test/api/simple.xml", "test/api/changed-super.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -109,7 +117,7 @@ public class ApiCheckTest extends TestCase { Report report = apiCheck.checkApi(args); assertEquals(0, report.errors().size()); } - + public void testInsertedSuper() { String[] args = { "test/api/inserted-super-1.xml", "test/api/inserted-super-2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -124,7 +132,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.ADDED_INTERFACE, report.errors().iterator().next().error()); } - + public void testRemovedInterface() { String[] args = { "test/api/medium.xml", "test/api/removed-interface.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -132,7 +140,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.REMOVED_INTERFACE, report.errors().iterator().next().error()); } - + public void testChangedAbstractClass() { String[] args = { "test/api/medium.xml", "test/api/changed-abstract.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -140,7 +148,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_ABSTRACT, report.errors().iterator().next().error()); } - + public void testChangedAbstractClass2() { String[] args = { "test/api/changed-abstract.xml", "test/api/medium.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -148,7 +156,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_ABSTRACT, report.errors().iterator().next().error()); } - + public void testChangedAbstractMethod() { String[] args = { "test/api/medium.xml", "test/api/changed-abstract2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -156,7 +164,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_ABSTRACT, report.errors().iterator().next().error()); } - + public void testChangedAbstractMethod2() { String[] args = { "test/api/changed-abstract2.xml", "test/api/medium.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -164,7 +172,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_ABSTRACT, report.errors().iterator().next().error()); } - + public void testAddedPackage() { String[] args = { "test/api/medium.xml", "test/api/added-package.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -172,7 +180,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.ADDED_PACKAGE, report.errors().iterator().next().error()); } - + public void testRemovedPackage() { String[] args = { "test/api/added-package.xml", "test/api/medium.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -180,7 +188,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.REMOVED_PACKAGE, report.errors().iterator().next().error()); } - + public void testChangedValue() { String[] args = { "test/api/constants.xml", "test/api/changed-value.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -188,7 +196,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_VALUE, report.errors().iterator().next().error()); } - + public void testChangedValue2() { String[] args = { "test/api/constants.xml", "test/api/changed-value2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -196,7 +204,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_VALUE, report.errors().iterator().next().error()); } - + public void testChangedType() { String[] args = { "test/api/constants.xml", "test/api/changed-type.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -204,39 +212,39 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_TYPE, report.errors().iterator().next().error()); } - + public void testChangedFinalField() { String[] args = { "test/api/constants.xml", "test/api/changed-final.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(1, report.errors().size()); - assertEquals(Errors.CHANGED_FINAL, report.errors().iterator().next().error()); + assertEquals(Errors.ADDED_FINAL, report.errors().iterator().next().error()); } - + public void testChangedFinalMethod() { String[] args = { "test/api/constants.xml", "test/api/changed-final2.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(1, report.errors().size()); - assertEquals(Errors.CHANGED_FINAL, report.errors().iterator().next().error()); + assertEquals(Errors.ADDED_FINAL, report.errors().iterator().next().error()); } - + public void testChangedFinalClass() { String[] args = { "test/api/constants.xml", "test/api/changed-final3.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(1, report.errors().size()); - assertEquals(Errors.CHANGED_FINAL, report.errors().iterator().next().error()); + assertEquals(Errors.ADDED_FINAL, report.errors().iterator().next().error()); } - + public void testChangedFinalClass2() { String[] args = { "test/api/changed-final3.xml", "test/api/constants.xml" }; ApiCheck apiCheck = new ApiCheck(); Report report = apiCheck.checkApi(args); assertEquals(1, report.errors().size()); - assertEquals(Errors.CHANGED_FINAL, report.errors().iterator().next().error()); + assertEquals(Errors.REMOVED_FINAL, report.errors().iterator().next().error()); } - + public void testAddedField() { String[] args = { "test/api/constants.xml", "test/api/added-field.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -244,7 +252,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.ADDED_FIELD, report.errors().iterator().next().error()); } - + public void testRemovedField() { String[] args = { "test/api/added-field.xml", "test/api/constants.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -252,7 +260,39 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.REMOVED_FIELD, report.errors().iterator().next().error()); } - + + public void testRemovedDeprecatedField() { + String[] args = { "test/api/added-deprecated-field.xml", "test/api/constants.xml" }; + ApiCheck apiCheck = new ApiCheck(); + Report report = apiCheck.checkApi(args); + assertEquals(1, report.errors().size()); + assertEquals(Errors.REMOVED_DEPRECATED_FIELD, report.errors().iterator().next().error()); + } + + public void testAddedMethod() { + String[] args = { "test/api/constants.xml", "test/api/added-method.xml" }; + ApiCheck apiCheck = new ApiCheck(); + Report report = apiCheck.checkApi(args); + assertEquals(1, report.errors().size()); + assertEquals(Errors.ADDED_METHOD, report.errors().iterator().next().error()); + } + + public void testRemovedMethod() { + String[] args = { "test/api/added-method.xml", "test/api/constants.xml" }; + ApiCheck apiCheck = new ApiCheck(); + Report report = apiCheck.checkApi(args); + assertEquals(1, report.errors().size()); + assertEquals(Errors.REMOVED_METHOD, report.errors().iterator().next().error()); + } + + public void testRemovedDeprecatedMethod() { + String[] args = { "test/api/added-deprecated-method.xml", "test/api/constants.xml" }; + ApiCheck apiCheck = new ApiCheck(); + Report report = apiCheck.checkApi(args); + assertEquals(1, report.errors().size()); + assertEquals(Errors.REMOVED_DEPRECATED_METHOD, report.errors().iterator().next().error()); + } + public void testChangedStaticMethod() { String[] args = { "test/api/constants.xml", "test/api/changed-static.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -260,7 +300,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_STATIC, report.errors().iterator().next().error()); } - + public void testChangedStaticClass() { String[] args = { "test/api/constants.xml", "test/api/changed-static2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -268,7 +308,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_STATIC, report.errors().iterator().next().error()); } - + public void testChangedStaticField() { String[] args = { "test/api/constants.xml", "test/api/changed-static3.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -276,7 +316,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_STATIC, report.errors().iterator().next().error()); } - + public void testChangedTransient() { String[] args = { "test/api/constants.xml", "test/api/changed-transient.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -284,7 +324,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_TRANSIENT, report.errors().iterator().next().error()); } - + public void testChangedSynchronized() { String[] args = { "test/api/constants.xml", "test/api/changed-synchronized.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -299,7 +339,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_VOLATILE, report.errors().iterator().next().error()); } - + public void testChangedNative() { String[] args = { "test/api/constants.xml", "test/api/changed-native.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -307,7 +347,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_NATIVE, report.errors().iterator().next().error()); } - + public void testChangedScopeMethod() { String[] args = { "test/api/constants.xml", "test/api/changed-scope.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -323,7 +363,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_SCOPE, report.errors().iterator().next().error()); } - + public void testChangedScopeClass2() { String[] args = { "test/api/constants.xml", "test/api/changed-scope2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -331,7 +371,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_SCOPE, report.errors().iterator().next().error()); } - + public void testChangedScopeField() { String[] args = { "test/api/constants.xml", "test/api/changed-scope3.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -339,7 +379,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_SCOPE, report.errors().iterator().next().error()); } - + public void testChangedConstructorScope() { String[] args = { "test/api/constants.xml", "test/api/changed-scope4.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -347,7 +387,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_SCOPE, report.errors().iterator().next().error()); } - + public void testChangedMethodThrows() { String[] args = { "test/api/throws.xml", "test/api/removed-exception.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -355,7 +395,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_THROWS, report.errors().iterator().next().error()); } - + public void testChangedMethodThrows2() { String[] args = { "test/api/removed-exception.xml", "test/api/throws.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -363,7 +403,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_THROWS, report.errors().iterator().next().error()); } - + public void testChangedConstructorThrows() { String[] args = { "test/api/throws.xml", "test/api/added-exception.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -371,7 +411,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_THROWS, report.errors().iterator().next().error()); } - + public void testChangedConstructorThrows2() { String[] args = { "test/api/added-exception.xml", "test/api/throws.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -379,7 +419,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_THROWS, report.errors().iterator().next().error()); } - + public void testChangedMethodDeprecated() { String[] args = { "test/api/constants.xml", "test/api/changed-deprecated.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -387,7 +427,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_DEPRECATED, report.errors().iterator().next().error()); } - + public void testChangedConstructorDeprecated() { String[] args = { "test/api/constants.xml", "test/api/changed-deprecated2.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -395,7 +435,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_DEPRECATED, report.errors().iterator().next().error()); } - + public void testChangedFieldDeprecated() { String[] args = { "test/api/constants.xml", "test/api/changed-deprecated3.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -403,7 +443,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_DEPRECATED, report.errors().iterator().next().error()); } - + public void testChangedClassToInterface() { String[] args = { "test/api/changed-class-info2.xml", "test/api/changed-class-info.xml" }; ApiCheck apiCheck = new ApiCheck(); @@ -411,7 +451,7 @@ public class ApiCheckTest extends TestCase { assertEquals(1, report.errors().size()); assertEquals(Errors.CHANGED_CLASS, report.errors().iterator().next().error()); } - + public void testChangedInterfaceToClass() { String[] args = { "test/api/changed-class-info.xml", "test/api/changed-class-info2.xml" }; ApiCheck apiCheck = new ApiCheck(); |