This commit is contained in:
Stephane Nicoll
2019-12-26 10:42:40 +01:00
parent 1e38dd5531
commit 2c1e81adf0
24 changed files with 65 additions and 78 deletions

View File

@@ -351,16 +351,13 @@ public abstract class AbstractApplicationContextRunner<SELF extends AbstractAppl
* @param consumer the consumer of the created {@link ApplicationContext}
* @return this instance
*/
@SuppressWarnings("unchecked")
public SELF run(ContextConsumer<? super A> consumer) {
withContextClassLoader(this.classLoader, () -> {
this.systemProperties.applyToSystemProperties(() -> {
try (A context = createAssertableContext()) {
accept(consumer, context);
}
return null;
});
});
withContextClassLoader(this.classLoader, () -> this.systemProperties.applyToSystemProperties(() -> {
try (A context = createAssertableContext()) {
accept(consumer, context);
}
return null;
}));
return (SELF) this;
}

View File

@@ -20,6 +20,7 @@ import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -307,7 +308,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
if (primaryBeanName != null) {
throw new NoUniqueBeanDefinitionException(type.resolve(), candidateBeanNames.size(),
"more than one 'primary' bean found among candidates: "
+ Arrays.asList(candidateBeanNames));
+ Collections.singletonList(candidateBeanNames));
}
primaryBeanName = candidateBeanName;
}