### Question:
FieldAccessor implements Accessor { public void setValue(Object object, Object newValue) throws PropertyException { if (newValue == null) { newValue = this.nullValue; } try { field.set(object, newValue); } catch (Throwable th) { throw new PropertyException( "Error writing field: " + field.getName(), this, object, th); } } FieldAccessor(Class<?> objectClass, String propertyName, Class<?> propertyType); String getName(); Object getValue(Object object); void setValue(Object object, Object newValue);  }### Answer:
@Test public void testSetValue() { TstFields object = new TstFields(); new FieldAccessor(TstFields.class, "stringField", String.class).setValue( object, "aaa"); assertEquals("aaa", object.stringField); byte[] bytes = new byte[] { 1, 2, 3 }; new FieldAccessor(TstFields.class, "byteArrayField", byte[].class).setValue( object, bytes); assertSame(bytes, object.byteArrayField); String[] strings = new String[] { "a", "b" }; new FieldAccessor(TstFields.class, "stringArrayField", String[].class).setValue( object, strings); assertSame(strings, object.stringArrayField); }
@Test public void testSetValuePrimitive() { TstFields object = new TstFields(); new FieldAccessor(TstFields.class, "intField", Integer.TYPE).setValue( object, new Integer(6)); assertEquals(6, object.intField); object.intField = 55; new FieldAccessor(TstFields.class, "intField", Integer.TYPE).setValue( object, null); assertEquals(0, object.intField); }