Ejemplo n.º 1
0
  private void testValidCopy(TestObject src, TestObject dest) {
    src.setName("freddie");
    src.setAge(15);
    src.setSpouse(new TestObject());
    assertFalse(src.getAge() == dest.getAge());

    ReflectionUtils.shallowCopyFieldState(src, dest);
    assertEquals(src.getAge(), dest.getAge());
    assertEquals(src.getSpouse(), dest.getSpouse());
  }
Ejemplo n.º 2
0
 @Test(expected = IllegalArgumentException.class)
 public void rejectsNullDest() {
   TestObject src = new TestObject();
   String dest = null;
   ReflectionUtils.shallowCopyFieldState(src, dest);
 }
Ejemplo n.º 3
0
 @Test(expected = IllegalArgumentException.class)
 public void copySrcToDestinationOfIncorrectClass() {
   TestObject src = new TestObject();
   String dest = new String();
   ReflectionUtils.shallowCopyFieldState(src, dest);
 }