Exemple #1
0
 private void testRemove2(CtClass cc, String fieldName) throws Exception {
   CtField f = cc.getField(fieldName);
   cc.removeField(f);
   try {
     CtField f2 = cc.getField(fieldName);
     fail("the removed field still exists");
   } catch (NotFoundException e) {
   }
 }
Exemple #2
0
  public void testRemove() throws Exception {
    CtClass cc = sloader.get("test2.Remove");
    testRemove2(cc, "f1");
    testRemove2(cc, "f6");
    testRemove2(cc, "f3");
    CtField p = cc.getField("p");
    try {
      cc.removeField(p);
      fail("non-existing field has been removed");
    } catch (NotFoundException e) {
    }

    testRemove3(cc, "bar");
    testRemove3(cc, "bar2");
    testRemove4(cc, "(I)V");
    cc.writeFile();
    Object obj = make(cc.getName());
    assertEquals(7, invoke(obj, "foo"));
  }