-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: testIssues in the test moduleIssues in the test moduletype: enhancementA general enhancementA general enhancement
Milestone
Description
Tadaya Tsuyukubo opened SPR-12611 and commented
Background
I want to write a custom profile resolver for @ActiveProfiles.
The profile resolution logic is to dynamically append profiles on top of profiles resolved by default logic. Since it is appending profiles, I wanted to either extend or delegate to the DefaultActiveProfilesResolver class to reuse the default logic.
public class MyProfileResolver extends DefaultActiveProfilesResolver {
@Override
public String[] resolve(Class<?> testClass) {
String[] profiles = super.resolve(testClass);
// my logic to append profiles
}
}public class MyProfileResolver implements ActiveProfilesResolver {
private final ActiveProfilesResolver defaultResolver = new DefaultActiveProfilesResolver();
@Override
public String[] resolve(Class<?> testClass) {
String[] profiles = defaultResolver.resolve(testClass);
// my logic to append profiles
}
}However, in DefaultActiveProfilesResolver, there is this check logic:
Class<? extends ActiveProfilesResolver> resolverClass = annAttrs.getClass("resolver");
if (!ActiveProfilesResolver.class.equals(resolverClass)) {
String msg = String.format("Configuration error for test class [%s]: %s cannot be used "
+ "in conjunction with custom resolver [%s].", rootDeclaringClass.getName(),
getClass().getSimpleName(), resolverClass.getName());
logger.error(msg);
throw new IllegalStateException(msg);
}Basically, this check logic prevents the reuse of the DefaultActiveProfilesResolver class.
Proposal
Can this check can be removed, or should this check be isAssignableFrom() instead of equals()?
Affects: 4.1 GA
Issue Links:
- Introduce bootstrap strategy in the TestContext framework [SPR-9955] #14588 Introduce bootstrap strategy in the TestContext framework ("depends on")
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test moduletype: enhancementA general enhancementA general enhancement