예제 #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());
  }
예제 #2
0
 @Test(expected = IllegalArgumentException.class)
 public void rejectsNullDest() {
   TestObject src = new TestObject();
   String dest = null;
   ReflectionUtils.shallowCopyFieldState(src, dest);
 }
예제 #3
0
 @Test(expected = IllegalArgumentException.class)
 public void copySrcToDestinationOfIncorrectClass() {
   TestObject src = new TestObject();
   String dest = new String();
   ReflectionUtils.shallowCopyFieldState(src, dest);
 }