aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java')
-rw-r--r--api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java33
1 files changed, 10 insertions, 23 deletions
diff --git a/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java b/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
index 26558cb..a85a52e 100644
--- a/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
+++ b/api/src/test/java/org/semver/jardiff/DeprecateDetectionTest.java
@@ -15,20 +15,14 @@
* limitations under the License.
*/
package org.semver.jardiff;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import junit.framework.Assert;
-
import org.junit.Test;
import org.objectweb.asm.ClassReader;
import org.osjava.jardiff.ClassInfo;
-import org.osjava.jardiff.DiffCriteria;
-import org.osjava.jardiff.DiffHandler;
import org.osjava.jardiff.JarDiff;
import org.osjava.jardiff.SimpleDiffCriteria;
import org.semver.Delta.Deprecate;
@@ -63,7 +57,7 @@ public class DeprecateDetectionTest {
}
@Test
- public void shouldInheritedMethodMatchImplementedMethod() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException {
+ public void shouldInheritedMethodMatchImplementedMethod() throws Exception {
/**
* The situation we are testing is as follows:
* Abstract class InheritanceRoot is initially implemented directly by ClassA.
@@ -77,25 +71,19 @@ public class DeprecateDetectionTest {
Map<String, ClassInfo> oldClassInfoMap = new HashMap<String, ClassInfo>();
Map<String, ClassInfo> newClassInfoMap = new HashMap<String, ClassInfo>();
JarDiff jd = new JarDiff();
- Method loadInfoMethod = JarDiff.class.getDeclaredMethod("loadClassInfo", ClassReader.class);
- Method diffMethod = JarDiff.class.getDeclaredMethod("diff", DiffHandler.class, DiffCriteria.class,
- String.class, String.class,
- Map.class, Map.class);
- diffMethod.setAccessible(true);
- loadInfoMethod.setAccessible(true);
- addClassInfo(oldClassInfoMap, ClassA.class, jd, loadInfoMethod);
- addClassInfo(oldClassInfoMap, DirectDescendant.class, jd, loadInfoMethod);
- addClassInfo(oldClassInfoMap, InheritanceRoot.class, jd, loadInfoMethod);
- addClassInfo(newClassInfoMap, ClassB.class, jd, loadInfoMethod);
- addClassInfo(newClassInfoMap, DirectDescendant.class, jd, loadInfoMethod);
- addClassInfo(newClassInfoMap, InheritanceRoot.class, jd, loadInfoMethod);
+ addClassInfo(oldClassInfoMap, ClassA.class, jd);
+ addClassInfo(oldClassInfoMap, DirectDescendant.class, jd);
+ addClassInfo(oldClassInfoMap, InheritanceRoot.class, jd);
+ addClassInfo(newClassInfoMap, ClassB.class, jd);
+ addClassInfo(newClassInfoMap, DirectDescendant.class, jd);
+ addClassInfo(newClassInfoMap, InheritanceRoot.class, jd);
// Make B look like A
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();
- diffMethod.invoke(jd, handler, new SimpleDiffCriteria(),
+ jd.diff(handler, new SimpleDiffCriteria(),
"0.1.0", "0.2.0", oldClassInfoMap, newClassInfoMap);
Dumper.dump(handler.getDelta());
@@ -111,9 +99,8 @@ public class DeprecateDetectionTest {
Assert.assertTrue("No Delta.Deprecate found", hasDeprecate);
}
- private void addClassInfo(Map<String, ClassInfo> classMap, Class klass, JarDiff jd,
- Method loadInfoMethod) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException {
- ClassInfo classInfo = (ClassInfo) loadInfoMethod.invoke(jd, new ClassReader(klass.getName()));
+ private void addClassInfo(Map<String, ClassInfo> classMap, Class klass, JarDiff jd) throws Exception {
+ ClassInfo classInfo = jd.loadClassInfo(new ClassReader(klass.getName()));
classMap.put(classInfo.getName(), classInfo);
}
}