aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-10-07 10:40:40 +0200
committerSven Gothel <[email protected]>2015-10-07 10:40:40 +0200
commit4f50b49c955f2bde2bb7eb4c7493206ec6bb1f2f (patch)
tree2e4c5ffd3c2396a6e695fa04345d6c151750fe0b /api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
parent0d2e314ef48bd2fd38b45f781c4573bdb2b32a69 (diff)
Fix JLS Binary Compat: Moving methods and fields upwards for classes _and_ interfaces is OKHEADmaster
- We shall also travers all interfaces upwards - All methods and fields found upwards must be tested for compatibility as well! Further: - Add class-name to Field- and MethodInfo via new intermediate AbstractMemberInfo. The class-name is used to have allow differs to find a class move upwards! - Pretty printing of class move binary-compatible change
Diffstat (limited to 'api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java')
-rw-r--r--api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java b/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
index a85a52e..4f1bc9e 100644
--- a/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
+++ b/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
@@ -43,7 +43,7 @@ public class DeprecateDetectionTest {
public static class ClassA extends InheritanceRoot {
@Override
public void aMethod() {}
-
+
public int aField = 0;
}
@@ -51,7 +51,7 @@ public class DeprecateDetectionTest {
@Override
@Deprecated
public void aMethod() {}
-
+
@Deprecated
public int aField = 0;
}
@@ -68,9 +68,9 @@ public class DeprecateDetectionTest {
* class declared twice in a test -- in real life, this would both be ClassA's,
* in different jars).
*/
- Map<String, ClassInfo> oldClassInfoMap = new HashMap<String, ClassInfo>();
- Map<String, ClassInfo> newClassInfoMap = new HashMap<String, ClassInfo>();
- JarDiff jd = new JarDiff();
+ final Map<String, ClassInfo> oldClassInfoMap = new HashMap<String, ClassInfo>();
+ final Map<String, ClassInfo> newClassInfoMap = new HashMap<String, ClassInfo>();
+ final JarDiff jd = new JarDiff();
addClassInfo(oldClassInfoMap, ClassA.class, jd);
addClassInfo(oldClassInfoMap, DirectDescendant.class, jd);
addClassInfo(oldClassInfoMap, InheritanceRoot.class, jd);
@@ -82,25 +82,26 @@ public class DeprecateDetectionTest {
newClassInfoMap.put("org/semver/jardiff/DeprecateDetectionTest$ClassA",
newClassInfoMap.get("org/semver/jardiff/DeprecateDetectionTest$ClassB"));
newClassInfoMap.remove("org/semver/jardiff/DeprecateDetectionTest$ClassB");
- DifferenceAccumulatingHandler handler = new DifferenceAccumulatingHandler();
- jd.diff(handler, new SimpleDiffCriteria(),
+ final DifferenceAccumulatingHandler handler = new DifferenceAccumulatingHandler();
+ jd.diff(handler, new SimpleDiffCriteria(true),
"0.1.0", "0.2.0", oldClassInfoMap, newClassInfoMap);
-
- Dumper.dump(handler.getDelta());
- Set<Difference> differences = handler.getDelta().getDifferences();
+ // Dumper.dump(handler.getDelta());
+ Dumper.dumpFullStats(handler.getDelta(), 4, System.out);
+
+ final Set<Difference> differences = handler.getDelta().getDifferences();
Assert.assertEquals("differences found", 3, differences.size());
// Naive search for Deprecate.
boolean hasDeprecate = false;
- for (Difference d : differences) {
+ for (final Difference d : differences) {
if (d instanceof Deprecate)
hasDeprecate = true;
}
Assert.assertTrue("No Delta.Deprecate found", hasDeprecate);
}
- private void addClassInfo(Map<String, ClassInfo> classMap, Class klass, JarDiff jd) throws Exception {
- ClassInfo classInfo = jd.loadClassInfo(new ClassReader(klass.getName()));
+ private void addClassInfo(final Map<String, ClassInfo> classMap, final Class klass, final JarDiff jd) throws Exception {
+ final ClassInfo classInfo = jd.loadClassInfo(new ClassReader(klass.getName()));
classMap.put(classInfo.getName(), classInfo);
}
}