reference, T referent, A attachment, Type type) {
assertEquals(referent, reference.get());
assertEquals(attachment, reference.getAttachment());
assertSame(type, reference.getType());
assertNotNull(reference.toString()); // make sure that no exception is thrown and that null is never returned
}
/**
* Assert that {@code reference} contains {@code referent}, {@code attachment}, and that its type is {@code type}.
* Also asserts that {@code reaper} is the reaper used by {@code referent}.
*
* Call this method only for {@link org.jboss.msc.ref.Reapable Reapable} references. This method assumes that
* {@code reference} has a method called {@code getReaper} that will return the reaper.
*
* @param the type of referent
* @param the type of attachment
* @param reference the {@code Reapable} reference that needs to be checked
* @param referent the expected content for {@code reference}
* @param attachment the expected attachment contained in {@code reference}
* @param type the expected type of {@code reference}
* @param reaper the expected reaper
*/
public static final void assertReference(Reference reference, T referent, A attachment, Type type, Reaper reaper) {
assertReference(reference, referent, attachment, type);
try {
assertEquals(reaper, reference.getClass().getMethod("getReaper").invoke(reference));
} catch (NoSuchMethodException e) {
fail("Can't find getReaper method at clas " + reference.getClass());
} catch (RuntimeException e) {
throw e;
}
catch (Exception e) {
fail(e.getMessage());
}
}
}