Enable reuse of DefaultActiveProfilesResolver

In order to allow DefaultActiveProfilesResolver to be reused (e.g., via
extension or delegation), the check which asserts that the 'resolver'
attribute of @ActiveProfiles is not set to a customer resolver class
has been removed.

Issue: SPR-12611
This commit is contained in:
Sam Brannen
2015-01-10 20:36:48 +01:00
parent cf7a7932f3
commit 276712dcd1
2 changed files with 41 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,7 +73,6 @@ public class DefaultActiveProfilesResolver implements ActiveProfilesResolver {
}
}
else {
Class<?> rootDeclaringClass = descriptor.getRootDeclaringClass();
Class<?> declaringClass = descriptor.getDeclaringClass();
AnnotationAttributes annAttrs = descriptor.getAnnotationAttributes();
@@ -82,15 +81,6 @@ public class DefaultActiveProfilesResolver implements ActiveProfilesResolver {
annAttrs, declaringClass.getName()));
}
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);
}
String[] profiles = annAttrs.getStringArray("profiles");
String[] valueProfiles = annAttrs.getStringArray("value");
boolean valueDeclared = !ObjectUtils.isEmpty(valueProfiles);