1 18 19 package alt.jiapi.file; 20 21 import java.io.InputStream ; 22 23 import junit.framework.TestCase; 24 25 30 public class ConstantPoolTest extends TestCase { 31 private ClassFile clazz; 32 33 public ConstantPoolTest(String name) { 34 super(name); 35 } 36 37 public String getName() { 38 return "ConstantPoolTest: " + super.getName(); 39 } 40 41 protected void setUp() { 42 try { 43 InputStream is = getClass().getResourceAsStream("/alt/jiapi/file/ClassFile.class"); 44 clazz = ClassFile.parse(is); 45 } 46 catch(Throwable t) { 47 System.out.println("Could not parse ClassFile: " + t); 48 } 49 } 50 51 public void testConstantPoolAddition() { 52 assertNotNull(clazz); 53 ConstantPool cp = clazz.getConstantPool(); 54 assertNotNull(cp); 55 56 ConstantPool.ClassInfo ci = cp.addClassInfo("test.Foo"); 58 ConstantPool.Entry entry = cp.get(ci.getEntryIndex()); 59 assertEquals(ci, entry); 60 61 63 ConstantPool.StringInfo si = cp.addStringInfo("Test String"); 64 entry = cp.get(si.getEntryIndex()); 65 assertEquals(si, entry); 66 67 } 69 } 70 | Popular Tags |