We are using the commons-lang equals, hashCode with reflection on the objects in our project. All our axon tests fail the equality test when we are using reflection.
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
We can get the tests to work if we don’t use the reflection.
There is this comment in the EqualsBuilder documentation.
Because these fields are usually private, the method, reflectionEquals
, usesAccessibleObject.setAccessible
to change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions are set up correctly. It is also slower than testing explicitly.
Is there something specific about how Axon is doing the compare of the aggregates in it’s testing framework that would prohibit the use of reflection?
Carol