Package collide.junit.cases

Examples of collide.junit.cases.ReflectionCaseNoMagic


    f.set(objects, objects);
  }
 
  @Test
  public void testDirectInjection_Declared() throws Exception{
    ReflectionCaseNoMagic superClass = new ReflectionCaseNoMagic();
    Field field = NO_MAGIC.getDeclaredField(PRIVATE_MEMBER);
    field.setAccessible(true);
    assertFalse(field.getBoolean(superClass));
    field.setBoolean(superClass, true);
    assertTrue(field.getBoolean(superClass));
View Full Code Here


  @Test
  public void testDirectInjection_Public() throws Exception{
    Field field = NO_MAGIC.getField(PUBLIC_MEMBER);
    field.setAccessible(true);
    assertFieldFalseToTrue(field, new ReflectionCaseNoMagic());
  }
View Full Code Here

//    assertFieldFalseToTrue(field, new ReflectionCaseNoMagic.Subclass());
//  }
 
  @Test
  public void testDirectInjection_Visibility() throws Exception{
    ReflectionCaseNoMagic superCase = new ReflectionCaseNoMagic();
    ReflectionCaseNoMagic.Subclass subCase = new ReflectionCaseNoMagic.Subclass();
   
    Field superField = NO_MAGIC.getField(OVERRIDE_FIELD);
    Field publicField = NO_MAGIC_SUBCLASS.getField(OVERRIDE_FIELD);
    Field declaredField = NO_MAGIC_SUBCLASS.getDeclaredField(OVERRIDE_FIELD);
    declaredField.setAccessible(true);
   
   
    assertFalse(declaredField.getBoolean(subCase));
    assertFalse(publicField.getBoolean(superCase));
    assertFalse(publicField.getBoolean(subCase));
    assertFalse(superField.getBoolean(subCase));
    assertFalse(superField.getBoolean(superCase));

    publicField.setBoolean(superCase, true);
    superField.setBoolean(subCase, true);
   
    assertTrue(superCase.overrideField);
    assertTrue(superCase.overrideField());
    assertTrue(subCase.overrideField());
    assertFalse(Subclass.getOverrideField(subCase));
   
    assertTrue(publicField.getBoolean(superCase));
    assertTrue(publicField.getBoolean(subCase));
View Full Code Here

    assertEquals("1", inst.value);
  }   
 
  @Test
  public void testDirectInjection_SubCase() throws Throwable {
    ReflectionCaseNoMagic inst;
    Constructor<? extends ReflectionCaseNoMagic> ctor;
   
    ctor = NO_MAGIC_SUBCLASS.getConstructor(CLS_LONG);
    inst = ctor.newInstance(1);
    assertNotNull(inst);
View Full Code Here

    method.invoke(list, 0, "Success!");
    assertEquals("Success!", list.get(0));
  };
  @Test
  public void testDeclaredMethodDirectly() throws Throwable {
    ReflectionCaseNoMagic superClass = new ReflectionCaseNoMagic();
    assertFalse(superClass.wasPrivateCalled());
    Method m = NO_MAGIC.getDeclaredMethod(PRIVATE_MEMBER);
    m.setAccessible(true);
    assertNotNull(m);
    m.invoke(superClass);
    assertTrue(superClass.wasPrivateCalled());
  };
View Full Code Here

    m.invoke(superClass);
    assertTrue(superClass.publicCall);
  }
  @Test
  public void testGetPublicMethodDirectly() throws Throwable {
    ReflectionCaseNoMagic noMagic = new ReflectionCaseNoMagic();
    Method m = NO_MAGIC.getMethod(METHOD_EQUALS, Object.class);
    assertNotNull(m);
    assertTrue((Boolean)m.invoke(noMagic, noMagic));
  }
View Full Code Here

  }
  @Test
  public void testGetPublicMethodInjectly() throws Throwable {
    Method m = GwtReflect.getPublicMethod(NO_MAGIC, METHOD_EQUALS, CLASS_OBJECT);
    assertNotNull(m);
    assertFalse((Boolean)m.invoke(new ReflectionCaseNoMagic(), new ReflectionCaseNoMagic()));
  }
View Full Code Here

    assertFalse((Boolean)m.invoke(new ReflectionCaseNoMagic(), new ReflectionCaseNoMagic()));
  }
 
  @Test
  public void testInvoke() throws Throwable {
    ReflectionCaseNoMagic inst = new ReflectionCaseNoMagic();
    assertFalse(inst.publicCall);
    assertFalse(inst.wasPrivateCalled());
   
    GwtReflect.invoke(NO_MAGIC, PUBLIC_MEMBER, ArrayConsts.EMPTY_CLASSES, inst, ArrayConsts.EMPTY_OBJECTS);
    assertTrue(inst.publicCall);
    assertFalse(inst.wasPrivateCalled());
   
    GwtReflect.invoke(NO_MAGIC, PRIVATE_MEMBER, ArrayConsts.EMPTY_CLASSES, inst, ArrayConsts.EMPTY_OBJECTS);
    assertTrue(inst.publicCall);
    assertTrue(inst.wasPrivateCalled());
   
  }
View Full Code Here

TOP

Related Classes of collide.junit.cases.ReflectionCaseNoMagic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.