Merge branch '2.7.x'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -36,11 +36,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.willReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Base class for tests for {@link DevToolsDataSourceAutoConfiguration}.
|
||||
@@ -54,7 +54,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
ConfigurableApplicationContext context = getContext(() -> createContext(SingleDataSourceConfiguration.class));
|
||||
DataSource dataSource = context.getBean(DataSource.class);
|
||||
Statement statement = configureDataSourceBehavior(dataSource);
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,7 +64,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
Collection<DataSource> dataSources = context.getBeansOfType(DataSource.class).values();
|
||||
for (DataSource dataSource : dataSources) {
|
||||
Statement statement = configureDataSourceBehavior(dataSource);
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
protected final Statement configureDataSourceBehavior(DataSource dataSource) throws SQLException {
|
||||
Connection connection = mock(Connection.class);
|
||||
Statement statement = mock(Statement.class);
|
||||
doReturn(connection).when(dataSource).getConnection();
|
||||
willReturn(connection).given(dataSource).getConnection();
|
||||
given(connection.createStatement()).willReturn(statement);
|
||||
return statement;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -27,8 +27,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DevToolsDataSourceAutoConfiguration} with an embedded data source.
|
||||
@@ -44,7 +44,7 @@ class DevToolsEmbeddedDataSourceAutoConfigurationTests extends AbstractDevToolsD
|
||||
DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -39,9 +39,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DevToolsDataSourceAutoConfiguration} with a pooled data source.
|
||||
@@ -66,7 +65,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
() -> createContext(DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement).execute("SHUTDOWN");
|
||||
then(statement).should().execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,7 +74,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,7 +83,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
"jdbc:h2:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +92,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(1)).execute("SHUTDOWN");
|
||||
then(statement).should().execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,7 +101,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
"jdbc:hsqldb:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,7 +110,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
"jdbc:hsqldb:mem:test", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(1)).execute("SHUTDOWN");
|
||||
then(statement).should().execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,7 +119,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
|
||||
"jdbc:derby://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
|
||||
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, never()).execute("SHUTDOWN");
|
||||
then(statement).should(never()).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -59,10 +59,10 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link LocalDevToolsAutoConfiguration}.
|
||||
@@ -124,7 +124,7 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
this.context.publishEvent(new ContextRefreshedEvent(this.context));
|
||||
verify(server).triggerReload();
|
||||
then(server).should().triggerReload();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +134,7 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
reset(server);
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false);
|
||||
this.context.publishEvent(event);
|
||||
verify(server).triggerReload();
|
||||
then(server).should().triggerReload();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +144,7 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
reset(server);
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), true);
|
||||
this.context.publishEvent(event);
|
||||
verify(server, never()).triggerReload();
|
||||
then(server).should(never()).triggerReload();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,7 +161,7 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
this.context = getContext(() -> initializeAndRun(Config.class));
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), true);
|
||||
this.context.publishEvent(event);
|
||||
verify(restarter).restart(any(FailureHandler.class));
|
||||
then(restarter).should().restart(any(FailureHandler.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,7 +169,7 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
this.context = getContext(() -> initializeAndRun(Config.class));
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false);
|
||||
this.context.publishEvent(event);
|
||||
verify(restarter, never()).restart();
|
||||
then(restarter).should(never()).restart();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.devtools.livereload.LiveReloadServer;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.willThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link OptionalLiveReloadServer}.
|
||||
@@ -46,7 +46,7 @@ class OptionalLiveReloadServerTests {
|
||||
willThrow(new RuntimeException("Error")).given(delegate).start();
|
||||
server.startServer();
|
||||
server.triggerReload();
|
||||
verify(delegate, never()).triggerReload();
|
||||
then(delegate).should(never()).triggerReload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -37,8 +37,8 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ClassPathFileChangeListener}.
|
||||
@@ -77,13 +77,13 @@ class ClassPathFileChangeListenerTests {
|
||||
@Test
|
||||
void sendsEventWithoutRestart() {
|
||||
testSendsEvent(false);
|
||||
verify(this.fileSystemWatcher, never()).stop();
|
||||
then(this.fileSystemWatcher).should(never()).stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendsEventWithRestart() {
|
||||
testSendsEvent(true);
|
||||
verify(this.fileSystemWatcher).stop();
|
||||
then(this.fileSystemWatcher).should().stop();
|
||||
}
|
||||
|
||||
private void testSendsEvent(boolean restart) {
|
||||
@@ -102,7 +102,7 @@ class ClassPathFileChangeListenerTests {
|
||||
given(this.restartStrategy.isRestartRequired(file2)).willReturn(true);
|
||||
}
|
||||
listener.onChange(changeSet);
|
||||
verify(this.eventPublisher).publishEvent(this.eventCaptor.capture());
|
||||
then(this.eventPublisher).should().publishEvent(this.eventCaptor.capture());
|
||||
ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor.getValue();
|
||||
assertThat(actualEvent.getChangeSet()).isEqualTo(changeSet);
|
||||
assertThat(actualEvent.isRestartRequired()).isEqualTo(restart);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -23,8 +23,8 @@ import java.io.OutputStream;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConnectionOutputStream}.
|
||||
@@ -40,7 +40,7 @@ class ConnectionOutputStreamTests {
|
||||
ConnectionOutputStream outputStream = new ConnectionOutputStream(out);
|
||||
byte[] b = new byte[100];
|
||||
outputStream.write(b, 1, 2);
|
||||
verify(out).write(b, 1, 2);
|
||||
then(out).should().write(b, 1, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -35,8 +35,8 @@ import org.springframework.http.client.ClientHttpResponse;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DelayedLiveReloadTrigger}.
|
||||
@@ -113,7 +113,7 @@ class DelayedLiveReloadTriggerTests {
|
||||
this.trigger.setTimings(10, 200, 30000);
|
||||
this.trigger.run();
|
||||
assertThat(System.currentTimeMillis() - startTime).isGreaterThan(300L);
|
||||
verify(this.liveReloadServer).triggerReload();
|
||||
then(this.liveReloadServer).should().triggerReload();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +121,7 @@ class DelayedLiveReloadTriggerTests {
|
||||
given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET)).willThrow(new IOException());
|
||||
this.trigger.setTimings(10, 0, 10);
|
||||
this.trigger.run();
|
||||
verify(this.liveReloadServer, never()).triggerReload();
|
||||
then(this.liveReloadServer).should(never()).triggerReload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -52,8 +52,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link RemoteClientConfiguration}.
|
||||
@@ -108,7 +108,7 @@ class RemoteClientConfigurationTests {
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
|
||||
this.clientContext.publishEvent(event);
|
||||
LiveReloadServer server = this.clientContext.getBean(LiveReloadServer.class);
|
||||
Awaitility.await().atMost(Duration.ofMinutes(1)).untilAsserted(() -> verify(server).triggerReload());
|
||||
Awaitility.await().atMost(Duration.ofMinutes(1)).untilAsserted(() -> then(server).should().triggerReload());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -40,10 +40,9 @@ import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.willReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link DispatcherFilter}.
|
||||
@@ -83,8 +82,8 @@ class DispatcherFilterTests {
|
||||
ServletRequest request = mock(ServletRequest.class);
|
||||
ServletResponse response = mock(ServletResponse.class);
|
||||
this.filter.doFilter(request, response, this.chain);
|
||||
verifyNoInteractions(this.dispatcher);
|
||||
verify(this.chain).doFilter(request, response);
|
||||
then(this.dispatcher).shouldHaveNoInteractions();
|
||||
then(this.chain).should().doFilter(request, response);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,7 +91,7 @@ class DispatcherFilterTests {
|
||||
HttpServletRequest request = new MockHttpServletRequest("GET", "/hello");
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
this.filter.doFilter(request, response, this.chain);
|
||||
verify(this.chain).doFilter(request, response);
|
||||
then(this.chain).should().doFilter(request, response);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,8 +100,8 @@ class DispatcherFilterTests {
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
willReturn(true).given(this.dispatcher).handle(any(ServerHttpRequest.class), any(ServerHttpResponse.class));
|
||||
this.filter.doFilter(request, response, this.chain);
|
||||
verifyNoInteractions(this.chain);
|
||||
verify(this.dispatcher).handle(this.serverRequestCaptor.capture(), this.serverResponseCaptor.capture());
|
||||
then(this.chain).shouldHaveNoInteractions();
|
||||
then(this.dispatcher).should().handle(this.serverRequestCaptor.capture(), this.serverResponseCaptor.capture());
|
||||
ServerHttpRequest dispatcherRequest = this.serverRequestCaptor.getValue();
|
||||
ServletServerHttpRequest actualRequest = (ServletServerHttpRequest) dispatcherRequest;
|
||||
ServerHttpResponse dispatcherResponse = this.serverResponseCaptor.getValue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -38,10 +38,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.withSettings;
|
||||
|
||||
/**
|
||||
@@ -81,7 +80,7 @@ class DispatcherTests {
|
||||
given(mapper.getHandler(any(ServerHttpRequest.class))).willReturn(handler);
|
||||
Dispatcher dispatcher = new Dispatcher(this.accessManager, Collections.singleton(mapper));
|
||||
dispatcher.handle(this.serverRequest, this.serverResponse);
|
||||
verifyNoInteractions(handler);
|
||||
then(handler).shouldHaveNoInteractions();
|
||||
assertThat(this.response.getStatus()).isEqualTo(403);
|
||||
}
|
||||
|
||||
@@ -93,7 +92,7 @@ class DispatcherTests {
|
||||
given(mapper.getHandler(any(ServerHttpRequest.class))).willReturn(handler);
|
||||
Dispatcher dispatcher = new Dispatcher(this.accessManager, Collections.singleton(mapper));
|
||||
dispatcher.handle(this.serverRequest, this.serverResponse);
|
||||
verify(handler).handle(this.serverRequest, this.serverResponse);
|
||||
then(handler).should().handle(this.serverRequest, this.serverResponse);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,8 +105,8 @@ class DispatcherTests {
|
||||
Dispatcher dispatcher = new Dispatcher(AccessManager.PERMIT_ALL, mappers);
|
||||
dispatcher.handle(this.serverRequest, this.serverResponse);
|
||||
InOrder inOrder = inOrder(mapper1, mapper2);
|
||||
inOrder.verify(mapper1).getHandler(this.serverRequest);
|
||||
inOrder.verify(mapper2).getHandler(this.serverRequest);
|
||||
then(mapper1).should(inOrder).getHandler(this.serverRequest);
|
||||
then(mapper2).should(inOrder).getHandler(this.serverRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -41,8 +41,8 @@ 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.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ClassLoaderFilesResourcePatternResolver}.
|
||||
@@ -112,7 +112,7 @@ class ClassLoaderFilesResourcePatternResolverTests {
|
||||
context.setResourceLoader(resourceLoader);
|
||||
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
|
||||
this.resolver.getResource("foo.txt");
|
||||
verify(resourceLoader).getResource("foo.txt");
|
||||
then(resourceLoader).should().getResource("foo.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +124,7 @@ class ClassLoaderFilesResourcePatternResolverTests {
|
||||
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
|
||||
Resource actual = this.resolver.getResource("foo:some-file.txt");
|
||||
assertThat(actual).isSameAs(resource);
|
||||
verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +136,7 @@ class ClassLoaderFilesResourcePatternResolverTests {
|
||||
context.addProtocolResolver(resolver);
|
||||
Resource actual = this.resolver.getResource("foo:some-file.txt");
|
||||
assertThat(actual).isSameAs(resource);
|
||||
verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,7 +146,7 @@ class ClassLoaderFilesResourcePatternResolverTests {
|
||||
context.setResourceLoader(resourceLoader);
|
||||
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
|
||||
this.resolver.getResource("foo.txt");
|
||||
verify(resourceLoader).getResource("foo.txt");
|
||||
then(resourceLoader).should().getResource("foo.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,7 +158,7 @@ class ClassLoaderFilesResourcePatternResolverTests {
|
||||
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
|
||||
Resource actual = this.resolver.getResource("foo:some-file.txt");
|
||||
assertThat(actual).isSameAs(resource);
|
||||
verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,7 +170,7 @@ class ClassLoaderFilesResourcePatternResolverTests {
|
||||
context.addProtocolResolver(resolver);
|
||||
Resource actual = this.resolver.getResource("foo:some-file.txt");
|
||||
assertThat(actual).isSameAs(resource);
|
||||
verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
|
||||
}
|
||||
|
||||
private ProtocolResolver mockProtocolResolver(String path, Resource resource) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -49,8 +49,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link Restarter}.
|
||||
@@ -140,7 +140,7 @@ class RestarterTests {
|
||||
ObjectFactory objectFactory = mock(ObjectFactory.class);
|
||||
Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
|
||||
assertThat(attribute).isEqualTo("abc");
|
||||
verifyNoInteractions(objectFactory);
|
||||
then(objectFactory).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -22,8 +22,8 @@ import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link HttpRestartServerHandler}.
|
||||
@@ -45,7 +45,7 @@ class HttpRestartServerHandlerTests {
|
||||
ServerHttpRequest request = mock(ServerHttpRequest.class);
|
||||
ServerHttpResponse response = mock(ServerHttpResponse.class);
|
||||
handler.handle(request, response);
|
||||
verify(server).handle(request, response);
|
||||
then(server).should().handle(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -38,8 +38,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
/**
|
||||
* Tests for {@link HttpRestartServer}.
|
||||
@@ -83,7 +82,7 @@ class HttpRestartServerTests {
|
||||
byte[] bytes = serialize(files);
|
||||
request.setContent(bytes);
|
||||
this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
|
||||
verify(this.delegate).updateAndRestart(this.filesCaptor.capture());
|
||||
then(this.delegate).should().updateAndRestart(this.filesCaptor.capture());
|
||||
assertThat(this.filesCaptor.getValue().getFile("name")).isNotNull();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
@@ -93,7 +92,7 @@ class HttpRestartServerTests {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
|
||||
verifyNoInteractions(this.delegate);
|
||||
then(this.delegate).shouldHaveNoInteractions();
|
||||
assertThat(response.getStatus()).isEqualTo(500);
|
||||
|
||||
}
|
||||
@@ -104,7 +103,7 @@ class HttpRestartServerTests {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
request.setContent(new byte[] { 0, 0, 0 });
|
||||
this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
|
||||
verifyNoInteractions(this.delegate);
|
||||
then(this.delegate).shouldHaveNoInteractions();
|
||||
assertThat(response.getStatus()).isEqualTo(500);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -39,9 +39,8 @@ import org.springframework.http.HttpStatus;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link HttpTunnelConnection}.
|
||||
@@ -109,10 +108,10 @@ class HttpTunnelConnectionTests {
|
||||
void closeTunnelCallsCloseableOnce() throws Exception {
|
||||
this.requestFactory.willRespondAfterDelay(1000, HttpStatus.GONE);
|
||||
WritableByteChannel channel = openTunnel(false);
|
||||
verify(this.closeable, never()).close();
|
||||
then(this.closeable).should(never()).close();
|
||||
channel.close();
|
||||
channel.close();
|
||||
verify(this.closeable, times(1)).close();
|
||||
then(this.closeable).should().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -22,8 +22,8 @@ import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link HttpTunnelServerHandler}.
|
||||
@@ -45,7 +45,7 @@ class HttpTunnelServerHandlerTests {
|
||||
ServerHttpRequest request = mock(ServerHttpRequest.class);
|
||||
ServerHttpResponse response = mock(ServerHttpResponse.class);
|
||||
handler.handle(request, response);
|
||||
verify(server).handle(request, response);
|
||||
then(server).should().handle(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,10 +50,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link HttpTunnelServer}.
|
||||
@@ -105,10 +104,10 @@ class HttpTunnelServerTests {
|
||||
|
||||
@Test
|
||||
void serverConnectedOnFirstRequest() throws Exception {
|
||||
verify(this.serverConnection, never()).open(anyInt());
|
||||
then(this.serverConnection).should(never()).open(anyInt());
|
||||
givenServerConnectionOpenWillAnswerWithServerChannel();
|
||||
this.server.handle(this.request, this.response);
|
||||
verify(this.serverConnection, times(1)).open(DEFAULT_LONG_POLL_TIMEOUT);
|
||||
then(this.serverConnection).should().open(DEFAULT_LONG_POLL_TIMEOUT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,7 +115,7 @@ class HttpTunnelServerTests {
|
||||
givenServerConnectionOpenWillAnswerWithServerChannel();
|
||||
this.server.setLongPollTimeout(800);
|
||||
this.server.handle(this.request, this.response);
|
||||
verify(this.serverConnection, times(1)).open(800);
|
||||
then(this.serverConnection).should().open(800);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -294,9 +293,9 @@ class HttpTunnelServerTests {
|
||||
given(request.getAsyncRequestControl(this.response)).willReturn(async);
|
||||
HttpConnection connection = new HttpConnection(request, this.response);
|
||||
connection.waitForResponse();
|
||||
verify(async).start();
|
||||
then(async).should().start();
|
||||
connection.respond(HttpStatus.NO_CONTENT);
|
||||
verify(async).complete();
|
||||
then(async).should().complete();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user