aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/test/java')
-rwxr-xr-xapi/src/test/java/org/semver/DeltaTest.java14
-rw-r--r--api/src/test/java/org/semver/jardiff/ClassInheritanceTest.java23
-rw-r--r--api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java27
3 files changed, 34 insertions, 30 deletions
diff --git a/api/src/test/java/org/semver/DeltaTest.java b/api/src/test/java/org/semver/DeltaTest.java
index 6548e61..241684b 100755
--- a/api/src/test/java/org/semver/DeltaTest.java
+++ b/api/src/test/java/org/semver/DeltaTest.java
@@ -91,7 +91,7 @@ public class DeltaTest {
final int patch = 3;
final Version version = new Version(major, minor, patch);
- final Version inferedVersion = new Delta(Collections.singleton(new Delta.Add("class", new FieldInfo(0, "", "", "", null))), false).infer(version);
+ final Version inferedVersion = new Delta(Collections.singleton(new Delta.Add("class", new FieldInfo("class", 0, "", "", "", null))), false).infer(version);
assertEquals(new Version(major, minor+1, 0), inferedVersion);
}
@@ -103,7 +103,7 @@ public class DeltaTest {
final int patch = 3;
final Version version = new Version(major, minor, patch);
- final Version inferedVersion = new Delta(Collections.singleton(new Delta.Change("class", new FieldInfo(0, "", "", "", null), new FieldInfo(0, "", "", "", null))), false).infer(version);
+ final Version inferedVersion = new Delta(Collections.singleton(new Delta.Change("class", new FieldInfo("class", 0, "", "", "", null), new FieldInfo("class", 0, "", "", "", null))), false).infer(version);
assertEquals(new Version(major+1, 0, 0), inferedVersion);
}
@@ -115,7 +115,7 @@ public class DeltaTest {
final int patch = 3;
final Version version = new Version(major, minor, patch);
- final Version inferedVersion = new Delta(Collections.singleton(new Delta.Remove("class", new FieldInfo(0, "", "", "", null))), false).infer(version);
+ final Version inferedVersion = new Delta(Collections.singleton(new Delta.Remove("class", new FieldInfo("class", 0, "", "", "", null))), false).infer(version);
assertEquals(new Version(major+1, 0, 0), inferedVersion);
}
@@ -157,7 +157,7 @@ public class DeltaTest {
@Test
public void shouldValidateWithIncorrectVersionFail() {
- validate(Collections.singleton(new Delta.Remove("class", new FieldInfo(0, "", "", "", null))), new Version(1, 1, 0), new Version(1, 1, 1), false);
+ validate(Collections.singleton(new Delta.Remove("class", new FieldInfo("class", 0, "", "", "", null))), new Version(1, 1, 0), new Version(1, 1, 1), false);
}
@Test
@@ -167,15 +167,15 @@ public class DeltaTest {
@Test
public void upgradeMinorVersionOnFieldDeprecated() {
- validate(singleton(new Delta.Deprecate("class", new FieldInfo(0, "", "", "", null), new FieldInfo(0, "", "", "", null))), new Version(1, 1, 0), new Version(1, 2, 0), true);
+ validate(singleton(new Delta.Deprecate("class", new FieldInfo("class", 0, "", "", "", null), new FieldInfo("class", 0, "", "", "", null))), new Version(1, 1, 0), new Version(1, 2, 0), true);
}
@Test
public void upgradeMinorVersionOnMethodDeprecated() {
- validate(singleton(new Delta.Deprecate("class", new MethodInfo(0, "", "", "", null), new MethodInfo(0, "", "", "", null))), new Version(1, 1, 0), new Version(1, 2, 0), true);
+ validate(singleton(new Delta.Deprecate("class", new MethodInfo("class", 0, "", "", "", null), new MethodInfo("class", 0, "", "", "", null))), new Version(1, 1, 0), new Version(1, 2, 0), true);
}
- private void validate(Set<? extends Delta.Difference> differences, Version previous, Version current, boolean valid) {
+ private void validate(final Set<? extends Delta.Difference> differences, final Version previous, final Version current, final boolean valid) {
assertEquals(
"accept differences " + differences + " when changing version from " + previous + " to " + current,
valid,
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);
}
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);
}
}