Commit 3dcb2d53 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.4.x' into 1.5.x

parents 8757ca77 c6bdd136
...@@ -65,7 +65,7 @@ public class ResetMocksTestExecutionListener extends AbstractTestExecutionListen ...@@ -65,7 +65,7 @@ public class ResetMocksTestExecutionListener extends AbstractTestExecutionListen
for (String name : names) { for (String name : names) {
BeanDefinition definition = beanFactory.getBeanDefinition(name); BeanDefinition definition = beanFactory.getBeanDefinition(name);
if (definition.isSingleton() && instantiatedSingletons.contains(name)) { if (definition.isSingleton() && instantiatedSingletons.contains(name)) {
Object bean = beanFactory.getBean(name); Object bean = beanFactory.getSingleton(name);
if (reset.equals(MockReset.get(bean))) { if (reset.equals(MockReset.get(bean))) {
Mockito.reset(bean); Mockito.reset(bean);
} }
......
...@@ -21,6 +21,7 @@ import org.junit.Test; ...@@ -21,6 +21,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService; import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
...@@ -37,6 +38,7 @@ import static org.mockito.Mockito.mock; ...@@ -37,6 +38,7 @@ import static org.mockito.Mockito.mock;
* Tests for {@link ResetMocksTestExecutionListener}. * Tests for {@link ResetMocksTestExecutionListener}.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Andy Wilkinson
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
...@@ -94,6 +96,31 @@ public class ResetMocksTestExecutionListenerTests { ...@@ -94,6 +96,31 @@ public class ResetMocksTestExecutionListenerTests {
throw new RuntimeException(); throw new RuntimeException();
} }
@Bean
public BrokenFactoryBean brokenFactoryBean() {
// gh-7270
return new BrokenFactoryBean();
}
}
static class BrokenFactoryBean implements FactoryBean<String> {
@Override
public String getObject() throws Exception {
throw new IllegalStateException();
}
@Override
public Class<?> getObjectType() {
return String.class;
}
@Override
public boolean isSingleton() {
return true;
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment