Exemplo n.º 1
0
 @BeforeClass(groups = "abstractmethod")
 public void setup() {
   ClassReplacer rep = new ClassReplacer();
   rep.queueClassForReplacement(AbstractClass.class, AbstractClass1.class);
   rep.queueClassForReplacement(AbstractCaller.class, AbstractCaller1.class);
   rep.queueClassForReplacement(BigChild.class, BigChild1.class);
   rep.queueClassForReplacement(SmallChild.class, SmallChild1.class);
   rep.replaceQueuedClasses();
 }
Exemplo n.º 2
0
  @Test
  public void testAddedClass() {
    ClassReplacer r = new ClassReplacer();
    r.queueClassForReplacement(ReplacedClass.class, ReplacedClass1.class);
    r.addNewClass(AddedClass1.class, "a.org.fakereplace.test.replacement.addedclass.AddedClass");
    r.replaceQueuedClasses();

    ReplacedClass c = new ReplacedClass();
    assert c.getValue().equals("hello Bob");
  }
 @Test
 public void testAnnotationA()
     throws SecurityException, NoSuchMethodException, IllegalArgumentException,
         IllegalAccessException, InvocationTargetException, NoSuchFieldException {
   ClassReplacer rep = new ClassReplacer();
   rep.queueClassForReplacement(AnnotationC.class, AnnotationC1.class);
   rep.replaceQueuedClasses();
   AnnotationC ns = new AnnotationC();
   Class c = AnnotationC.class;
   Assert.assertFalse(ns.getClass().isAnnotationPresent(AnnotationA.class));
   Field field = c.getDeclaredField("field");
   Assert.assertTrue(field.isAnnotationPresent(AnnotationA.class));
   Assert.assertEquals("1", field.getAnnotation(AnnotationA.class).value().value());
 }