I have a class which implements a interface. That class has a private double field field1
which reads value from application properties using @Value
spring annotation.
I'm developing tests and I need to populate that field from that class. To achieve that I'm using:
ReflectionTestUtils.setField(Class.class, "field1", value, double.class);
I'm getting always null pointer exception, but the debug log shows:
DEBUG org.springframework.test.util.ReflectionTestUtils - Setting field 'field1' of type [double] on target object [null] or target class [class com.a.b.c.Class] to value [value]
.
Does someone know how can I set value to this field using reflection or just how to populate some value to this class field? I don't have any instance of that class, but interfaces.
Aucun commentaire:
Enregistrer un commentaire