1 32 33 package com.jeantessier.diff; 34 35 import java.io.*; 36 import java.util.*; 37 38 import junit.framework.*; 39 40 import com.jeantessier.classreader.*; 41 42 public class TestDeprecatableDifferences extends TestCase { 43 private DifferencesFactory factory; 44 private ClassfileLoader oldLoader; 45 private ClassfileLoader newLoader; 46 47 protected void setUp() throws Exception { 48 Validator validator = new ListBasedValidator(new BufferedReader(new StringReader(""))); 49 factory = new DifferencesFactory(validator, validator); 50 51 oldLoader = new AggregatingClassfileLoader(); 52 oldLoader.load(Collections.singleton("tests" + File.separator + "JarJarDiff" + File.separator + "old")); 53 54 newLoader = new AggregatingClassfileLoader(); 55 newLoader.load(Collections.singleton("tests" + File.separator + "JarJarDiff" + File.separator + "new")); 56 } 57 58 public void testNotDeprecatedNotDeprecatedDifferent() { 59 String name = "ModifiedPackage.ModifiedClass"; 60 Classfile oldClassfile = oldLoader.getClassfile(name); 61 assertNotNull(oldClassfile); 62 Classfile newClassfile = newLoader.getClassfile(name); 63 assertNotNull(newClassfile); 64 Differences componentDifferences = factory.createClassDifferences(name, oldClassfile, newClassfile); 65 assertTrue("component IsEmpty()", !componentDifferences.isEmpty()); 66 67 DeprecatableDifferences deprecatedDifferences = new DeprecatableDifferences(componentDifferences, oldClassfile, newClassfile); 68 69 assertTrue("deprecated NewDeprecation()", !deprecatedDifferences.isNewDeprecation()); 70 assertTrue("deprecated RemovedDeprecation()", !deprecatedDifferences.isRemovedDeprecation()); 71 assertTrue("deprecated IsEmpty()", !deprecatedDifferences.isEmpty()); 72 } 73 74 public void testNotDeprecatedNotDeprecatedSame() { 75 String name = "ModifiedPackage.ModifiedClass"; 76 Classfile oldClassfile = newLoader.getClassfile(name); 77 assertNotNull(oldClassfile); 78 Classfile newClassfile = newLoader.getClassfile(name); 79 assertNotNull(newClassfile); 80 Differences componentDifferences = new ClassDifferences(name, oldClassfile, newClassfile); 81 assertTrue("component IsEmpty()", componentDifferences.isEmpty()); 82 83 DeprecatableDifferences deprecatedDifferences = new DeprecatableDifferences(componentDifferences, oldClassfile, newClassfile); 84 85 assertTrue("deprecated NewDeprecation()", !deprecatedDifferences.isNewDeprecation()); 86 assertTrue("deprecated RemovedDeprecation()", !deprecatedDifferences.isRemovedDeprecation()); 87 assertTrue("deprecated IsEmpty()", deprecatedDifferences.isEmpty()); 88 } 89 90 public void testDeprecatedNotDeprecated() { 91 String name = "ModifiedPackage.UndeprecatedClass"; 92 Classfile oldClassfile = oldLoader.getClassfile(name); 93 assertNotNull(oldClassfile); 94 Classfile newClassfile = newLoader.getClassfile(name); 95 assertNotNull(newClassfile); 96 Differences componentDifferences = new ClassDifferences(name, oldClassfile, newClassfile); 97 assertTrue("component not empty", componentDifferences.isEmpty()); 98 99 DeprecatableDifferences deprecatedDifferences = new DeprecatableDifferences(componentDifferences, oldClassfile, newClassfile); 100 101 assertTrue("deprecated NewDeprecation()", !deprecatedDifferences.isNewDeprecation()); 102 assertTrue("deprecated RemovedDeprecation()", deprecatedDifferences.isRemovedDeprecation()); 103 assertTrue("deprecated IsEmpty()", !deprecatedDifferences.isEmpty()); 104 } 105 106 public void testNotDeprecatedDeprecated() { 107 String name = "ModifiedPackage.DeprecatedClass"; 108 Classfile oldClassfile = oldLoader.getClassfile(name); 109 assertNotNull(oldClassfile); 110 Classfile newClassfile = newLoader.getClassfile(name); 111 assertNotNull(newClassfile); 112 Differences componentDifferences = new ClassDifferences(name, oldClassfile, newClassfile); 113 assertTrue("component not empty", componentDifferences.isEmpty()); 114 115 DeprecatableDifferences deprecatedDifferences = new DeprecatableDifferences(componentDifferences, oldClassfile, newClassfile); 116 117 assertTrue("deprecated NewDeprecation()", deprecatedDifferences.isNewDeprecation()); 118 assertTrue("deprecated RemovedDeprecation()", !deprecatedDifferences.isRemovedDeprecation()); 119 assertTrue("deprecated IsEmpty()", !deprecatedDifferences.isEmpty()); 120 } 121 122 public void testDeprecatedDeprecated() { 123 String name = "ModifiedPackage.DeprecatedClass"; 124 Classfile oldClassfile = newLoader.getClassfile(name); 125 assertNotNull(oldClassfile); 126 Classfile newClassfile = newLoader.getClassfile(name); 127 assertNotNull(newClassfile); 128 Differences componentDifferences = new ClassDifferences(name, oldClassfile, newClassfile); 129 assertTrue("component not empty", componentDifferences.isEmpty()); 130 131 DeprecatableDifferences deprecatedDifferences = new DeprecatableDifferences(componentDifferences, oldClassfile, newClassfile); 132 133 assertTrue("deprecated NewDeprecation()", !deprecatedDifferences.isNewDeprecation()); 134 assertTrue("deprecated RemovedDeprecation()", !deprecatedDifferences.isRemovedDeprecation()); 135 assertTrue("deprecated IsEmpty()", deprecatedDifferences.isEmpty()); 136 } 137 } 138 | Popular Tags |