Check SQL dependency in super class for SqlIntegrationMembershipTest (#398)

In some cases, we define JpaTransactionManagerRule in a TestCase
class which is extended by the concrete test class. So, we need
to check if JpaTransactionManagerRule is also defined in the super
class.
This commit is contained in:
Shicong Huang 2019-12-05 13:12:56 -05:00 committed by GitHub
parent 369c1259fb
commit 988f78274e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,8 +71,13 @@ public class SqlIntegrationMembershipTest {
}
private static boolean isSqlDependent(Class<?> testClass) {
return Stream.of(testClass.getDeclaredFields())
.map(Field::getType)
.anyMatch(JpaTransactionManagerRule.class::equals);
for (Class<?> clazz = testClass; clazz != null; clazz = clazz.getSuperclass()) {
if (Stream.of(clazz.getDeclaredFields())
.map(Field::getType)
.anyMatch(JpaTransactionManagerRule.class::equals)) {
return true;
}
}
return false;
}
}