pull/2430/merge
Phillip Webb 8 years ago
parent 6776ec2704
commit 0cc313f224

@ -27,8 +27,8 @@ import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageChannel;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
/** /**

@ -35,9 +35,9 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.util.StreamUtils; import org.springframework.util.StreamUtils;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**

@ -41,9 +41,9 @@ import org.mockito.stubbing.Answer;
import org.springframework.boot.cli.testutil.SystemProperties; import org.springframework.boot.cli.testutil.SystemProperties;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
/** /**
* Tests for {@link SettingsXmlRepositorySystemSessionAutoConfiguration}. * Tests for {@link SettingsXmlRepositorySystemSessionAutoConfiguration}.

@ -95,19 +95,17 @@ final class SpringBootMockUtil {
private static class Mockito1MockUtilAdapter implements MockUtilAdapter { private static class Mockito1MockUtilAdapter implements MockUtilAdapter {
private final MockUtil mockUtil = BeanUtils.instantiate(MockUtil.class); private final MockUtil mockUtil = BeanUtils.instantiateClass(MockUtil.class);
private final Method getMockSettingsMethod = ReflectionUtils private final Method getMockSettingsMethod = ReflectionUtils
.findMethod(MockUtil.class, "getMockSettings", Object.class); .findMethod(MockUtil.class, "getMockSettings", Object.class);
private static final MockingProgress mockingProgress = private static final MockingProgress mockingProgress = createThreadSafeMockingProgress();
createThreadSafeMockingProgress();
private final Method reportMatcherMethod = ReflectionUtils.findMethod( private final Method reportMatcherMethod = ReflectionUtils
ArgumentMatcherStorage.class, "reportMatcher", Matcher.class); .findMethod(ArgumentMatcherStorage.class, "reportMatcher", Matcher.class);
private static final Constructor<MockAwareVerificationMode> mockAwareVerificationModeConstructor = private static final Constructor<MockAwareVerificationMode> mockAwareVerificationModeConstructor = getMockAwareVerificationModeConstructor();
getMockAwareVerificationModeConstructor();
private static MockingProgress createThreadSafeMockingProgress() { private static MockingProgress createThreadSafeMockingProgress() {
try { try {

@ -643,11 +643,11 @@ public class SpringApplicationTests {
} }
catch (RuntimeException ex) { catch (RuntimeException ex) {
} }
ArgumentCaptor<RuntimeException> ac = ArgumentCaptor.forClass( ArgumentCaptor<RuntimeException> exceptionCaptor = ArgumentCaptor
RuntimeException.class); .forClass(RuntimeException.class);
verify(handler).registerLoggedException(ac.capture()); verify(handler).registerLoggedException(exceptionCaptor.capture());
RuntimeException exception = ac.getValue(); assertThat(exceptionCaptor.getValue())
assertThat(exception).hasCauseInstanceOf(RefreshFailureException.class); .hasCauseInstanceOf(RefreshFailureException.class);
assertThat(this.output.toString()).doesNotContain("NullPointerException"); assertThat(this.output.toString()).doesNotContain("NullPointerException");
} }

@ -38,8 +38,8 @@ import org.mockito.stubbing.Answer;
import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletContextInitializer;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
@ -132,8 +132,7 @@ public class MockEmbeddedServletContainerFactory
@Override @Override
public Void answer(InvocationOnMock invocation) public Void answer(InvocationOnMock invocation)
throws Throwable { throws Throwable {
initParameters.put( initParameters.put(invocation.getArgument(0),
invocation.getArgument(0),
invocation.getArgument(1)); invocation.getArgument(1));
return null; return null;
} }
@ -146,8 +145,7 @@ public class MockEmbeddedServletContainerFactory
@Override @Override
public String answer(InvocationOnMock invocation) public String answer(InvocationOnMock invocation)
throws Throwable { throws Throwable {
return initParameters return initParameters.get(invocation.getArgument(0));
.get(invocation.getArgument(0));
} }
}); });
given(this.servletContext.getAttributeNames()).willReturn( given(this.servletContext.getAttributeNames()).willReturn(

@ -33,8 +33,8 @@ import org.springframework.web.util.UriTemplateHandler;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
/** /**
@ -61,8 +61,7 @@ public class RootUriTemplateHandlerTests {
this.uri = new URI("http://example.com/hello"); this.uri = new URI("http://example.com/hello");
this.handler = new RootUriTemplateHandler("http://example.com", this.delegate); this.handler = new RootUriTemplateHandler("http://example.com", this.delegate);
given(this.delegate.expand(anyString(), any(Map.class))).willReturn(this.uri); given(this.delegate.expand(anyString(), any(Map.class))).willReturn(this.uri);
given(this.delegate.expand(anyString(), (Object[]) any())) given(this.delegate.expand(anyString(), (Object[]) any())).willReturn(this.uri);
.willReturn(this.uri);
} }
@Test @Test

Loading…
Cancel
Save