public void testSetValue() {
TestFields object = new TestFields();
// string
new FieldAccessor(TestFields.class, "stringField", String.class).setValue(
object,
"aaa");
assertEquals("aaa", object.stringField);
// primitive array
byte[] bytes = new byte[] {
1, 2, 3
};
new FieldAccessor(TestFields.class, "byteArrayField", byte[].class).setValue(
object,
bytes);
assertSame(bytes, object.byteArrayField);
// object array
String[] strings = new String[] {
"a", "b"
};
new FieldAccessor(TestFields.class, "stringArrayField", String[].class).setValue(
object,
strings);
assertSame(strings, object.stringArrayField);
}