aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/test/java/org/semver/jardiff/ClassInheritanceTest.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/ClassInheritanceTest.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/ClassInheritanceTest.java')
-rw-r--r--api/src/test/java/org/semver/jardiff/ClassInheritanceTest.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/api/src/test/java/org/semver/jardiff/ClassInheritanceTest.java b/api/src/test/java/org/semver/jardiff/ClassInheritanceTest.java
index aea74fa..0682032 100644
--- a/api/src/test/java/org/semver/jardiff/ClassInheritanceTest.java
+++ b/api/src/test/java/org/semver/jardiff/ClassInheritanceTest.java
@@ -25,6 +25,7 @@ import org.osjava.jardiff.ClassInfo;
import org.osjava.jardiff.JarDiff;
import org.osjava.jardiff.SimpleDiffCriteria;
import org.semver.Delta;
+import org.semver.Dumper;
import org.semver.Delta.Change;
public class ClassInheritanceTest {
@@ -58,9 +59,9 @@ public class ClassInheritanceTest {
* 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);
@@ -69,17 +70,19 @@ public class ClassInheritanceTest {
addClassInfo(newClassInfoMap, InheritanceRoot.class, jd);
// Make B look like A
- ClassInfo a = oldClassInfoMap.get("org/semver/jardiff/ClassInheritanceTest$ClassA");
- ClassInfo b = newClassInfoMap.get("org/semver/jardiff/ClassInheritanceTest$ClassB");
+ final ClassInfo a = oldClassInfoMap.get("org/semver/jardiff/ClassInheritanceTest$ClassA");
+ final ClassInfo b = newClassInfoMap.get("org/semver/jardiff/ClassInheritanceTest$ClassB");
newClassInfoMap.put(a.getName(), new ClassInfo(b.getVersion(), b.getAccess(), a.getName(),
b.getSignature(), b.getSupername(), b.getInterfaces(),
b.getMethodMap(), b.getFieldMap()));
newClassInfoMap.remove(b.getName());
- 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);
- for (Delta.Difference d: handler.getDelta().getDifferences()) {
+ Dumper.dumpFullStats(handler.getDelta(), 4, System.out);
+
+ for (final Delta.Difference d: handler.getDelta().getDifferences()) {
System.err.println(d.getClassName() + " : " + d.getClass().getName()
+ " : " + d.getInfo().getName() + " : " + d.getInfo().getAccessType());
if (d instanceof Change) {
@@ -89,8 +92,8 @@ public class ClassInheritanceTest {
Assert.assertEquals("differences found", 1, handler.getDelta().getDifferences().size());
}
- 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);
}