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.
|
||||
@@ -39,8 +39,8 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
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 SharedMetadataReaderFactoryContextInitializer}.
|
||||
@@ -84,7 +84,7 @@ class SharedMetadataReaderFactoryContextInitializerTests {
|
||||
assertThat(bean).isSameAs(configurationAnnotationPostProcessor);
|
||||
ArgumentCaptor<MetadataReaderFactory> metadataReaderFactory = ArgumentCaptor
|
||||
.forClass(MetadataReaderFactory.class);
|
||||
verify(configurationAnnotationPostProcessor).setMetadataReaderFactory(metadataReaderFactory.capture());
|
||||
then(configurationAnnotationPostProcessor).should().setMetadataReaderFactory(metadataReaderFactory.capture());
|
||||
assertThat(metadataReaderFactory.getValue())
|
||||
.isInstanceOf(ConcurrentReferenceCachingMetadataReaderFactory.class);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -84,9 +84,9 @@ import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Tests for {@link RabbitAutoConfiguration}.
|
||||
@@ -179,10 +179,10 @@ class RabbitAutoConfigurationTests {
|
||||
given(rcf.newConnection(isNull(), eq(addresses), anyString())).willReturn(mock(Connection.class));
|
||||
ReflectionTestUtils.setField(connectionFactory, "rabbitConnectionFactory", rcf);
|
||||
connectionFactory.createConnection();
|
||||
verify(rcf).newConnection(isNull(), eq(addresses), eq("test#0"));
|
||||
then(rcf).should().newConnection(isNull(), eq(addresses), eq("test#0"));
|
||||
connectionFactory.resetConnection();
|
||||
connectionFactory.createConnection();
|
||||
verify(rcf).newConnection(isNull(), eq(addresses), eq("test#1"));
|
||||
then(rcf).should().newConnection(isNull(), eq(addresses), eq("test#1"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -360,10 +360,11 @@ class RabbitAutoConfigurationTests {
|
||||
RabbitTemplate template = mock(RabbitTemplate.class);
|
||||
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
|
||||
configurer.configure(template, connectionFactory);
|
||||
verify(template).setMessageConverter(context.getBean("myMessageConverter", MessageConverter.class));
|
||||
verify(template).setExchange("my-exchange");
|
||||
verify(template).setRoutingKey("my-routing-key");
|
||||
verify(template).setDefaultReceiveQueue("default-queue");
|
||||
then(template).should()
|
||||
.setMessageConverter(context.getBean("myMessageConverter", MessageConverter.class));
|
||||
then(template).should().setExchange("my-exchange");
|
||||
then(template).should().setRoutingKey("my-routing-key");
|
||||
then(template).should().setDefaultReceiveQueue("default-queue");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -434,7 +435,7 @@ class RabbitAutoConfigurationTests {
|
||||
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
|
||||
.getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class);
|
||||
rabbitListenerContainerFactory.setBatchSize(10);
|
||||
verify(rabbitListenerContainerFactory).setBatchSize(10);
|
||||
then(rabbitListenerContainerFactory).should().setBatchSize(10);
|
||||
assertThat(rabbitListenerContainerFactory.getAdviceChain()).isNull();
|
||||
});
|
||||
}
|
||||
@@ -554,9 +555,9 @@ class RabbitAutoConfigurationTests {
|
||||
.getBean(SimpleRabbitListenerContainerFactoryConfigurer.class);
|
||||
SimpleRabbitListenerContainerFactory factory = mock(SimpleRabbitListenerContainerFactory.class);
|
||||
configurer.configure(factory, mock(ConnectionFactory.class));
|
||||
verify(factory).setConcurrentConsumers(5);
|
||||
verify(factory).setMaxConcurrentConsumers(10);
|
||||
verify(factory).setPrefetchCount(40);
|
||||
then(factory).should().setConcurrentConsumers(5);
|
||||
then(factory).should().setMaxConcurrentConsumers(10);
|
||||
then(factory).should().setPrefetchCount(40);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -568,7 +569,7 @@ class RabbitAutoConfigurationTests {
|
||||
.getBean(SimpleRabbitListenerContainerFactoryConfigurer.class);
|
||||
SimpleRabbitListenerContainerFactory factory = mock(SimpleRabbitListenerContainerFactory.class);
|
||||
configurer.configure(factory, mock(ConnectionFactory.class));
|
||||
verify(factory).setConsumerBatchEnabled(true);
|
||||
then(factory).should().setConsumerBatchEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -583,9 +584,9 @@ class RabbitAutoConfigurationTests {
|
||||
.getBean(DirectRabbitListenerContainerFactoryConfigurer.class);
|
||||
DirectRabbitListenerContainerFactory factory = mock(DirectRabbitListenerContainerFactory.class);
|
||||
configurer.configure(factory, mock(ConnectionFactory.class));
|
||||
verify(factory).setConsumersPerQueue(5);
|
||||
verify(factory).setPrefetchCount(40);
|
||||
verify(factory).setDeBatchingEnabled(false);
|
||||
then(factory).should().setConsumersPerQueue(5);
|
||||
then(factory).should().setPrefetchCount(40);
|
||||
then(factory).should().setDeBatchingEnabled(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -608,7 +609,7 @@ class RabbitAutoConfigurationTests {
|
||||
Message message = mock(Message.class);
|
||||
Exception ex = new Exception("test");
|
||||
mir.recover(new Object[] { "foo", message }, ex);
|
||||
verify(messageRecoverer).recover(message, ex);
|
||||
then(messageRecoverer).should().recover(message, ex);
|
||||
RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(advice, "retryOperations");
|
||||
assertThat(retryTemplate).isNotNull();
|
||||
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) ReflectionTestUtils.getField(retryTemplate, "retryPolicy");
|
||||
@@ -849,8 +850,8 @@ class RabbitAutoConfigurationTests {
|
||||
ConnectionFactoryCustomizer.class);
|
||||
InOrder inOrder = inOrder(firstCustomizer, secondCustomizer);
|
||||
com.rabbitmq.client.ConnectionFactory targetConnectionFactory = getTargetConnectionFactory(context);
|
||||
inOrder.verify(firstCustomizer).customize(targetConnectionFactory);
|
||||
inOrder.verify(secondCustomizer).customize(targetConnectionFactory);
|
||||
then(firstCustomizer).should(inOrder).customize(targetConnectionFactory);
|
||||
then(secondCustomizer).should(inOrder).customize(targetConnectionFactory);
|
||||
inOrder.verifyNoMoreInteractions();
|
||||
});
|
||||
}
|
||||
@@ -859,7 +860,7 @@ class RabbitAutoConfigurationTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
void whenASimpleContainerCustomizerIsDefinedThenItIsCalledToConfigureTheContainer() {
|
||||
this.contextRunner.withUserConfiguration(SimpleContainerCustomizerConfiguration.class)
|
||||
.run((context) -> verify(context.getBean(ContainerCustomizer.class))
|
||||
.run((context) -> then(context.getBean(ContainerCustomizer.class)).should()
|
||||
.configure(any(SimpleMessageListenerContainer.class)));
|
||||
}
|
||||
|
||||
@@ -868,7 +869,7 @@ class RabbitAutoConfigurationTests {
|
||||
void whenADirectContainerCustomizerIsDefinedThenItIsCalledToConfigureTheContainer() {
|
||||
this.contextRunner.withUserConfiguration(DirectContainerCustomizerConfiguration.class)
|
||||
.withPropertyValues("spring.rabbitmq.listener.type:direct")
|
||||
.run((context) -> verify(context.getBean(ContainerCustomizer.class))
|
||||
.run((context) -> then(context.getBean(ContainerCustomizer.class)).should()
|
||||
.configure(any(DirectMessageListenerContainer.class)));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,8 @@ import org.springframework.rabbit.stream.producer.RabbitStreamTemplate;
|
||||
import org.springframework.rabbit.stream.support.converter.StreamMessageConverter;
|
||||
|
||||
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;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link RabbitStreamConfiguration}.
|
||||
@@ -67,7 +66,7 @@ class RabbitStreamConfigurationTests {
|
||||
assertThat(listenerContainer).extracting("consumerCustomizer").isNotNull();
|
||||
assertThat(context.getBean(StreamRabbitListenerContainerFactory.class))
|
||||
.extracting("nativeListener", InstanceOfAssertFactories.BOOLEAN).isFalse();
|
||||
verify(context.getBean(ContainerCustomizer.class)).configure(listenerContainer);
|
||||
then(context.getBean(ContainerCustomizer.class)).should().configure(listenerContainer);
|
||||
assertThat(context).hasSingleBean(Environment.class);
|
||||
});
|
||||
}
|
||||
@@ -105,12 +104,12 @@ class RabbitStreamConfigurationTests {
|
||||
EnvironmentBuilder builder = mock(EnvironmentBuilder.class);
|
||||
RabbitProperties properties = new RabbitProperties();
|
||||
RabbitStreamConfiguration.configure(builder, properties);
|
||||
verify(builder).port(5552);
|
||||
verify(builder).host("localhost");
|
||||
verify(builder).lazyInitialization(true);
|
||||
verify(builder).username("guest");
|
||||
verify(builder).password("guest");
|
||||
verifyNoMoreInteractions(builder);
|
||||
then(builder).should().port(5552);
|
||||
then(builder).should().host("localhost");
|
||||
then(builder).should().lazyInitialization(true);
|
||||
then(builder).should().username("guest");
|
||||
then(builder).should().password("guest");
|
||||
then(builder).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,7 +118,7 @@ class RabbitStreamConfigurationTests {
|
||||
RabbitProperties properties = new RabbitProperties();
|
||||
properties.getStream().setPort(5553);
|
||||
RabbitStreamConfiguration.configure(builder, properties);
|
||||
verify(builder).port(5553);
|
||||
then(builder).should().port(5553);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +127,7 @@ class RabbitStreamConfigurationTests {
|
||||
RabbitProperties properties = new RabbitProperties();
|
||||
properties.getStream().setHost("stream.rabbit.example.com");
|
||||
RabbitStreamConfiguration.configure(builder, properties);
|
||||
verify(builder).host("stream.rabbit.example.com");
|
||||
then(builder).should().host("stream.rabbit.example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,8 +137,8 @@ class RabbitStreamConfigurationTests {
|
||||
properties.setUsername("alice");
|
||||
properties.setPassword("secret");
|
||||
RabbitStreamConfiguration.configure(builder, properties);
|
||||
verify(builder).username("alice");
|
||||
verify(builder).password("secret");
|
||||
then(builder).should().username("alice");
|
||||
then(builder).should().password("secret");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,8 +150,8 @@ class RabbitStreamConfigurationTests {
|
||||
properties.getStream().setUsername("bob");
|
||||
properties.getStream().setPassword("confidential");
|
||||
RabbitStreamConfiguration.configure(builder, properties);
|
||||
verify(builder).username("bob");
|
||||
verify(builder).password("confidential");
|
||||
then(builder).should().username("bob");
|
||||
then(builder).should().password("confidential");
|
||||
}
|
||||
|
||||
@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.
|
||||
@@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
|
||||
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link BatchDataSourceScriptDatabaseInitializer}.
|
||||
@@ -42,7 +42,7 @@ class BatchDataSourceScriptDatabaseInitializerTests {
|
||||
properties.getJdbc());
|
||||
assertThat(settings.getSchemaLocations())
|
||||
.containsOnly("classpath:org/springframework/batch/core/schema-test.sql");
|
||||
verifyNoInteractions(dataSource);
|
||||
then(dataSource).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -31,8 +31,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link CassandraAutoConfiguration}.
|
||||
@@ -61,7 +61,7 @@ class CassandraAutoConfigurationIntegrationTests {
|
||||
context.getBean(CqlSession.class);
|
||||
DriverConfigLoader driverConfigLoader = context.getBean(DriverConfigLoader.class);
|
||||
context.close();
|
||||
verify(driverConfigLoader).close();
|
||||
then(driverConfigLoader).should().close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -41,9 +41,8 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
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.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link EntityScanner}.
|
||||
@@ -112,10 +111,10 @@ class EntityScannerTests {
|
||||
TestEntityScanner scanner = new TestEntityScanner(context, candidateComponentProvider);
|
||||
scanner.scan(Entity.class);
|
||||
ArgumentCaptor<AnnotationTypeFilter> annotationTypeFilter = ArgumentCaptor.forClass(AnnotationTypeFilter.class);
|
||||
verify(candidateComponentProvider).addIncludeFilter(annotationTypeFilter.capture());
|
||||
verify(candidateComponentProvider)
|
||||
then(candidateComponentProvider).should().addIncludeFilter(annotationTypeFilter.capture());
|
||||
then(candidateComponentProvider).should()
|
||||
.findCandidateComponents("org.springframework.boot.autoconfigure.domain.scan");
|
||||
verifyNoMoreInteractions(candidateComponentProvider);
|
||||
then(candidateComponentProvider).shouldHaveNoMoreInteractions();
|
||||
assertThat(annotationTypeFilter.getValue().getAnnotationType()).isEqualTo(Entity.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link ElasticsearchRestClientAutoConfiguration}.
|
||||
@@ -257,7 +257,7 @@ class ElasticsearchRestClientAutoConfigurationTests {
|
||||
assertThat(context).hasSingleBean(Sniffer.class);
|
||||
Sniffer sniffer = context.getBean(Sniffer.class);
|
||||
assertThat(sniffer).isSameAs(customSniffer);
|
||||
verifyNoInteractions(customSniffer);
|
||||
then(customSniffer).shouldHaveNoInteractions();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -33,9 +33,9 @@ import org.springframework.context.annotation.Configuration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link FlywayAutoConfiguration} with Flyway 7.x.
|
||||
@@ -70,8 +70,8 @@ class Flyway7xAutoConfigurationTests {
|
||||
assertThat(flyway.getConfiguration().getCallbacks()).hasSize(2);
|
||||
assertThat(flyway.getConfiguration().getCallbacks()).containsExactlyInAnyOrder(callbackTwo,
|
||||
callbackOne);
|
||||
verify(callbackOne, atLeastOnce()).handle(any(Event.class), any(Context.class));
|
||||
verify(callbackTwo, atLeastOnce()).handle(any(Event.class), any(Context.class));
|
||||
then(callbackOne).should(atLeastOnce()).handle(any(Event.class), any(Context.class));
|
||||
then(callbackTwo).should(atLeastOnce()).handle(any(Event.class), any(Context.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
|
||||
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link IntegrationDataSourceScriptDatabaseInitializer}.
|
||||
@@ -42,7 +42,7 @@ class IntegrationDataSourceScriptDatabaseInitializerTests {
|
||||
properties.getJdbc());
|
||||
assertThat(settings.getSchemaLocations())
|
||||
.containsOnly("classpath:org/springframework/integration/jdbc/schema-test.sql");
|
||||
verifyNoInteractions(dataSource);
|
||||
then(dataSource).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.springframework.jdbc.BadSqlGrammarException;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
||||
/**
|
||||
* Tests for {@link JooqExceptionTranslator}
|
||||
@@ -54,7 +54,7 @@ class JooqExceptionTranslatorTests {
|
||||
given(context.sqlException()).willReturn(sqlException);
|
||||
this.exceptionTranslator.exception(context);
|
||||
ArgumentCaptor<RuntimeException> captor = ArgumentCaptor.forClass(RuntimeException.class);
|
||||
verify(context).exception(captor.capture());
|
||||
then(context).should().exception(captor.capture());
|
||||
assertThat(captor.getValue()).isInstanceOf(BadSqlGrammarException.class);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class JooqExceptionTranslatorTests {
|
||||
given(configuration.dialect()).willReturn(SQLDialect.POSTGRES);
|
||||
given(context.sqlException()).willReturn(new SQLException(null, null, 123456789));
|
||||
this.exceptionTranslator.exception(context);
|
||||
verify(context, times(0)).exception(any());
|
||||
then(context).should(never()).exception(any());
|
||||
}
|
||||
|
||||
static Object[] exceptionTranslation() {
|
||||
|
||||
@@ -33,9 +33,9 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
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.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link JooqProperties}.
|
||||
@@ -59,7 +59,7 @@ class JooqPropertiesTests {
|
||||
DataSource dataSource = mockStandaloneDataSource();
|
||||
SQLDialect sqlDialect = properties.determineSqlDialect(dataSource);
|
||||
assertThat(sqlDialect).isEqualTo(SQLDialect.POSTGRES);
|
||||
verify(dataSource, never()).getConnection();
|
||||
then(dataSource).should(never()).getConnection();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -76,9 +76,9 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link KafkaAutoConfiguration}.
|
||||
@@ -333,10 +333,10 @@ class KafkaAutoConfigurationTests {
|
||||
.asProperties();
|
||||
assertThat((List<String>) configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG))
|
||||
.containsExactly("localhost:9092", "localhost:9093");
|
||||
verify(context.getBean("&firstStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class), never())
|
||||
.setAutoStartup(false);
|
||||
verify(context.getBean("&secondStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class),
|
||||
never()).setAutoStartup(false);
|
||||
then(context.getBean("&firstStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class))
|
||||
.should(never()).setAutoStartup(false);
|
||||
then(context.getBean("&secondStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class))
|
||||
.should(never()).setAutoStartup(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -38,10 +38,9 @@ import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
|
||||
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.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link MailSenderAutoConfiguration}.
|
||||
@@ -224,7 +223,7 @@ class MailSenderAutoConfigurationTests {
|
||||
.withPropertyValues("spring.mail.host:10.0.0.23", "spring.mail.test-connection:true").run((context) -> {
|
||||
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
|
||||
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
|
||||
verify(mailSender, times(1)).testConnection();
|
||||
then(mailSender).should().testConnection();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -235,7 +234,7 @@ class MailSenderAutoConfigurationTests {
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
|
||||
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
|
||||
verify(mailSender, never()).testConnection();
|
||||
then(mailSender).should(never()).testConnection();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -30,8 +30,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link MongoClientFactorySupport}.
|
||||
@@ -97,7 +97,7 @@ abstract class MongoClientFactorySupportTests<T> {
|
||||
void customizerIsInvoked() {
|
||||
MongoClientSettingsBuilderCustomizer customizer = mock(MongoClientSettingsBuilderCustomizer.class);
|
||||
createMongoClient(customizer);
|
||||
verify(customizer).customize(any(MongoClientSettings.Builder.class));
|
||||
then(customizer).should().customize(any(MongoClientSettings.Builder.class));
|
||||
}
|
||||
|
||||
@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.
|
||||
@@ -36,8 +36,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link HibernateProperties}.
|
||||
@@ -141,14 +141,14 @@ class HibernatePropertiesTests {
|
||||
assertThat(hibernateProperties).doesNotContainKey(AvailableSettings.HBM2DDL_AUTO);
|
||||
assertThat(hibernateProperties).containsEntry(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
|
||||
"drop-and-create");
|
||||
verify(this.ddlAutoSupplier, never()).get();
|
||||
then(this.ddlAutoSupplier).should(never()).get();
|
||||
}));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertDefaultDdlAutoNotInvoked(String expectedDdlAuto) {
|
||||
return assertHibernateProperties((hibernateProperties) -> {
|
||||
assertThat(hibernateProperties).containsEntry(AvailableSettings.HBM2DDL_AUTO, expectedDdlAuto);
|
||||
verify(this.ddlAutoSupplier, never()).get();
|
||||
then(this.ddlAutoSupplier).should(never()).get();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link QuartzAutoConfiguration}.
|
||||
@@ -164,7 +164,7 @@ class QuartzAutoConfigurationTests {
|
||||
Scheduler scheduler = context.getBean(Scheduler.class);
|
||||
assertThat(scheduler.getMetaData().getThreadPoolSize()).isEqualTo(50);
|
||||
Executor executor = context.getBean(Executor.class);
|
||||
verifyNoInteractions(executor);
|
||||
then(executor).shouldHaveNoInteractions();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -26,9 +26,8 @@ import org.springframework.boot.sql.init.DatabaseInitializationSettings;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
|
||||
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;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link QuartzDataSourceScriptDatabaseInitializer}.
|
||||
@@ -46,7 +45,7 @@ class QuartzDataSourceScriptDatabaseInitializerTests {
|
||||
properties);
|
||||
assertThat(settings.getSchemaLocations())
|
||||
.containsOnly("classpath:org/quartz/impl/jdbcjobstore/tables_test.sql");
|
||||
verifyNoInteractions(dataSource);
|
||||
then(dataSource).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +57,7 @@ class QuartzDataSourceScriptDatabaseInitializerTests {
|
||||
mock(DataSource.class), properties);
|
||||
ResourceDatabasePopulator populator = mock(ResourceDatabasePopulator.class);
|
||||
initializer.customize(populator);
|
||||
verify(populator).setCommentPrefixes("##", "--");
|
||||
then(populator).should().setCommentPrefixes("##", "--");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
|
||||
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link JdbcSessionDataSourceScriptDatabaseInitializer}.
|
||||
@@ -42,7 +42,7 @@ class JdbcSessionDataSourceScriptDatabaseInitializerTests {
|
||||
properties);
|
||||
assertThat(settings.getSchemaLocations())
|
||||
.containsOnly("classpath:org/springframework/session/jdbc/schema-test.sql");
|
||||
verifyNoInteractions(dataSource);
|
||||
then(dataSource).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,9 +36,8 @@ import org.springframework.session.jdbc.JdbcIndexedSessionRepository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Hazelcast specific tests for {@link SessionAutoConfiguration}.
|
||||
@@ -80,7 +79,7 @@ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigur
|
||||
assertThat(repository).hasFieldOrPropertyWithValue("defaultMaxInactiveInterval",
|
||||
(int) new ServerProperties().getServlet().getSession().getTimeout().getSeconds());
|
||||
HazelcastInstance hazelcastInstance = context.getBean(HazelcastInstance.class);
|
||||
verify(hazelcastInstance, times(1)).getMap("spring:session:sessions");
|
||||
then(hazelcastInstance).should().getMap("spring:session:sessions");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +88,7 @@ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigur
|
||||
"spring.session.hazelcast.map-name=foo:bar:biz").run((context) -> {
|
||||
validateSessionRepository(context, HazelcastIndexedSessionRepository.class);
|
||||
HazelcastInstance hazelcastInstance = context.getBean(HazelcastInstance.class);
|
||||
verify(hazelcastInstance, times(1)).getMap("foo:bar:biz");
|
||||
then(hazelcastInstance).should().getMap("foo:bar:biz");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -22,8 +22,8 @@ import java.util.function.Supplier;
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link SessionProperties}.
|
||||
@@ -39,7 +39,7 @@ class SessionPropertiesTests {
|
||||
properties.setTimeout(Duration.ofMinutes(1));
|
||||
Supplier<Duration> fallback = mock(Supplier.class);
|
||||
assertThat(properties.determineTimeout(fallback)).isEqualTo(Duration.ofMinutes(1));
|
||||
verifyNoInteractions(fallback);
|
||||
then(fallback).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@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.
|
||||
@@ -43,8 +43,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
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 TaskExecutionAutoConfiguration}.
|
||||
@@ -119,7 +119,7 @@ class TaskExecutionAutoConfigurationTests {
|
||||
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
|
||||
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
|
||||
ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build();
|
||||
verify(customizer).customize(executor);
|
||||
then(customizer).should().customize(executor);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -32,9 +32,9 @@ import org.springframework.mock.env.MockEnvironment;
|
||||
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.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link TemplateAvailabilityProviders}.
|
||||
@@ -76,7 +76,7 @@ class TemplateAvailabilityProvidersTests {
|
||||
given(applicationContext.getClassLoader()).willReturn(this.classLoader);
|
||||
TemplateAvailabilityProviders providers = new TemplateAvailabilityProviders(applicationContext);
|
||||
assertThat(providers.getProviders()).isNotEmpty();
|
||||
verify(applicationContext).getClassLoader();
|
||||
then(applicationContext).should().getClassLoader();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +145,8 @@ class TemplateAvailabilityProvidersTests {
|
||||
TemplateAvailabilityProvider found = this.providers.getProvider(this.view, this.environment, this.classLoader,
|
||||
this.resourceLoader);
|
||||
assertThat(found).isNull();
|
||||
verify(this.provider).isTemplateAvailable(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
then(this.provider).should().isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
this.resourceLoader);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,7 +165,7 @@ class TemplateAvailabilityProvidersTests {
|
||||
.willReturn(true);
|
||||
this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
verify(this.provider, times(1)).isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
then(this.provider).should().isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
this.resourceLoader);
|
||||
}
|
||||
|
||||
@@ -172,7 +173,7 @@ class TemplateAvailabilityProvidersTests {
|
||||
void getProviderShouldCacheNoMatchResult() {
|
||||
this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
verify(this.provider, times(1)).isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
then(this.provider).should().isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
this.resourceLoader);
|
||||
}
|
||||
|
||||
@@ -183,7 +184,7 @@ class TemplateAvailabilityProvidersTests {
|
||||
this.environment.setProperty("spring.template.provider.cache", "false");
|
||||
this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader);
|
||||
verify(this.provider, times(2)).isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
then(this.provider).should(times(2)).isTemplateAvailable(this.view, this.environment, this.classLoader,
|
||||
this.resourceLoader);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -33,10 +33,9 @@ import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ValidatorAdapter}.
|
||||
@@ -63,11 +62,11 @@ class ValidatorAdapterTests {
|
||||
void wrapperInvokesCallbackOnNonManagedBean() {
|
||||
this.contextRunner.withUserConfiguration(NonManagedBeanConfig.class).run((context) -> {
|
||||
LocalValidatorFactoryBean validator = context.getBean(NonManagedBeanConfig.class).validator;
|
||||
verify(validator, times(1)).setApplicationContext(any(ApplicationContext.class));
|
||||
verify(validator, times(1)).afterPropertiesSet();
|
||||
verify(validator, never()).destroy();
|
||||
then(validator).should().setApplicationContext(any(ApplicationContext.class));
|
||||
then(validator).should().afterPropertiesSet();
|
||||
then(validator).should(never()).destroy();
|
||||
context.close();
|
||||
verify(validator, times(1)).destroy();
|
||||
then(validator).should().destroy();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,11 +74,11 @@ class ValidatorAdapterTests {
|
||||
void wrapperDoesNotInvokeCallbackOnManagedBean() {
|
||||
this.contextRunner.withUserConfiguration(ManagedBeanConfig.class).run((context) -> {
|
||||
LocalValidatorFactoryBean validator = context.getBean(ManagedBeanConfig.class).validator;
|
||||
verify(validator, never()).setApplicationContext(any(ApplicationContext.class));
|
||||
verify(validator, never()).afterPropertiesSet();
|
||||
verify(validator, never()).destroy();
|
||||
then(validator).should(never()).setApplicationContext(any(ApplicationContext.class));
|
||||
then(validator).should(never()).afterPropertiesSet();
|
||||
then(validator).should(never()).destroy();
|
||||
context.close();
|
||||
verify(validator, never()).destroy();
|
||||
then(validator).should(never()).destroy();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -44,9 +44,8 @@ import org.springframework.web.client.RestTemplate;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
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;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link RestTemplateAutoConfiguration}
|
||||
@@ -115,7 +114,7 @@ class RestTemplateAutoConfigurationTests {
|
||||
assertThat(context).hasSingleBean(RestTemplate.class);
|
||||
RestTemplate restTemplate = context.getBean(RestTemplate.class);
|
||||
RestTemplateCustomizer customizer = context.getBean(RestTemplateCustomizer.class);
|
||||
verify(customizer).customize(restTemplate);
|
||||
then(customizer).should().customize(restTemplate);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,7 +127,7 @@ class RestTemplateAutoConfigurationTests {
|
||||
assertThat(restTemplate.getMessageConverters()).hasSize(1);
|
||||
assertThat(restTemplate.getMessageConverters().get(0))
|
||||
.isInstanceOf(CustomHttpMessageConverter.class);
|
||||
verifyNoInteractions(context.getBean(RestTemplateCustomizer.class));
|
||||
then(context.getBean(RestTemplateCustomizer.class)).shouldHaveNoInteractions();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -143,7 +142,7 @@ class RestTemplateAutoConfigurationTests {
|
||||
assertThat(restTemplate.getMessageConverters().get(0))
|
||||
.isInstanceOf(CustomHttpMessageConverter.class);
|
||||
RestTemplateCustomizer customizer = context.getBean(RestTemplateCustomizer.class);
|
||||
verify(customizer).customize(restTemplate);
|
||||
then(customizer).should().customize(restTemplate);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -54,8 +54,8 @@ import org.springframework.test.context.support.TestPropertySourceUtils;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
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 JettyWebServerFactoryCustomizer}.
|
||||
@@ -85,14 +85,14 @@ class JettyWebServerFactoryCustomizerTests {
|
||||
this.environment.setProperty("DYNO", "-");
|
||||
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultUseForwardHeaders() {
|
||||
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(false);
|
||||
then(factory).should().setUseForwardHeaders(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,7 +100,7 @@ class JettyWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE);
|
||||
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,7 +109,7 @@ class JettyWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NONE);
|
||||
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(false);
|
||||
then(factory).should().setUseForwardHeaders(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,7 +256,7 @@ class JettyWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ForwardHeadersStrategy.NATIVE);
|
||||
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,10 +38,10 @@ import org.springframework.util.unit.DataSize;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link NettyWebServerFactoryCustomizer}.
|
||||
@@ -75,14 +75,14 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
this.environment.setProperty("DYNO", "-");
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultUseForwardHeaders() {
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(false);
|
||||
then(factory).should().setUseForwardHeaders(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,7 +90,7 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE);
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +99,7 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NONE);
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(false);
|
||||
then(factory).should().setUseForwardHeaders(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +136,7 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
nettyProperties.setMaxInitialLineLength(DataSize.ofKilobytes(32));
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory, times(1)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
then(factory).should().addServerCustomizers(this.customizerCaptor.capture());
|
||||
NettyServerCustomizer serverCustomizer = this.customizerCaptor.getValue();
|
||||
HttpServer httpServer = serverCustomizer.apply(HttpServer.create());
|
||||
HttpRequestDecoderSpec decoder = httpServer.configuration().decoder();
|
||||
@@ -149,10 +149,10 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
|
||||
private void verifyConnectionTimeout(NettyReactiveWebServerFactory factory, Integer expected) {
|
||||
if (expected == null) {
|
||||
verify(factory, never()).addServerCustomizers(any(NettyServerCustomizer.class));
|
||||
then(factory).should(never()).addServerCustomizers(any(NettyServerCustomizer.class));
|
||||
return;
|
||||
}
|
||||
verify(factory, times(2)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
then(factory).should(times(2)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
NettyServerCustomizer serverCustomizer = this.customizerCaptor.getAllValues().get(0);
|
||||
HttpServer httpServer = serverCustomizer.apply(HttpServer.create());
|
||||
Map<ChannelOption<?>, ?> options = httpServer.configuration().options();
|
||||
@@ -161,10 +161,10 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
|
||||
private void verifyIdleTimeout(NettyReactiveWebServerFactory factory, Duration expected) {
|
||||
if (expected == null) {
|
||||
verify(factory, never()).addServerCustomizers(any(NettyServerCustomizer.class));
|
||||
then(factory).should(never()).addServerCustomizers(any(NettyServerCustomizer.class));
|
||||
return;
|
||||
}
|
||||
verify(factory, times(2)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
then(factory).should(times(2)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
NettyServerCustomizer serverCustomizer = this.customizerCaptor.getAllValues().get(0);
|
||||
HttpServer httpServer = serverCustomizer.apply(HttpServer.create());
|
||||
Duration idleTimeout = httpServer.configuration().idleTimeout();
|
||||
@@ -172,7 +172,7 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
}
|
||||
|
||||
private void verifyMaxKeepAliveRequests(NettyReactiveWebServerFactory factory, int expected) {
|
||||
verify(factory, times(2)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
then(factory).should(times(2)).addServerCustomizers(this.customizerCaptor.capture());
|
||||
NettyServerCustomizer serverCustomizer = this.customizerCaptor.getAllValues().get(0);
|
||||
HttpServer httpServer = serverCustomizer.apply(HttpServer.create());
|
||||
int maxKeepAliveRequests = httpServer.configuration().maxKeepAliveRequests();
|
||||
|
||||
@@ -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,9 +41,9 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.willAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link UndertowWebServerFactoryCustomizer}.
|
||||
@@ -77,12 +77,12 @@ class UndertowWebServerFactoryCustomizerTests {
|
||||
"server.undertow.accesslog.dir=test-logs", "server.undertow.accesslog.rotate=false");
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setAccessLogEnabled(true);
|
||||
verify(factory).setAccessLogPattern("foo");
|
||||
verify(factory).setAccessLogPrefix("test_log");
|
||||
verify(factory).setAccessLogSuffix("txt");
|
||||
verify(factory).setAccessLogDirectory(new File("test-logs"));
|
||||
verify(factory).setAccessLogRotate(false);
|
||||
then(factory).should().setAccessLogEnabled(true);
|
||||
then(factory).should().setAccessLogPattern("foo");
|
||||
then(factory).should().setAccessLogPrefix("test_log");
|
||||
then(factory).should().setAccessLogSuffix("txt");
|
||||
then(factory).should().setAccessLogDirectory(new File("test-logs"));
|
||||
then(factory).should().setAccessLogRotate(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,7 +138,7 @@ class UndertowWebServerFactoryCustomizerTests {
|
||||
bind("server.undertow.threads.io=4");
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setIoThreads(4);
|
||||
then(factory).should().setIoThreads(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,7 +146,7 @@ class UndertowWebServerFactoryCustomizerTests {
|
||||
bind("server.undertow.threads.worker=10");
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setWorkerThreads(10);
|
||||
then(factory).should().setWorkerThreads(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -202,14 +202,14 @@ class UndertowWebServerFactoryCustomizerTests {
|
||||
this.environment.setProperty("DYNO", "-");
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultUseForwardHeaders() {
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(false);
|
||||
then(factory).should().setUseForwardHeaders(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,7 +217,7 @@ class UndertowWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE);
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
then(factory).should().setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,7 +226,7 @@ class UndertowWebServerFactoryCustomizerTests {
|
||||
this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NONE);
|
||||
ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(false);
|
||||
then(factory).should().setUseForwardHeaders(false);
|
||||
}
|
||||
|
||||
private <T> T boundServerOption(Option<T> option) {
|
||||
|
||||
@@ -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.
|
||||
@@ -53,9 +53,8 @@ import org.springframework.web.server.adapter.ForwardedHeaderTransformer;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ReactiveWebServerFactoryAutoConfiguration}.
|
||||
@@ -128,7 +127,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer",
|
||||
TomcatConnectorCustomizer.class);
|
||||
assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Connector.class));
|
||||
then(customizer).should().customize(any(Connector.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -145,7 +144,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer",
|
||||
TomcatConnectorCustomizer.class);
|
||||
assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Connector.class));
|
||||
then(customizer).should().customize(any(Connector.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -161,7 +160,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class);
|
||||
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
|
||||
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Context.class));
|
||||
then(customizer).should().customize(any(Context.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,7 +176,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class);
|
||||
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
|
||||
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Context.class));
|
||||
then(customizer).should().customize(any(Context.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,7 +193,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
TomcatProtocolHandlerCustomizer<?> customizer = context.getBean("protocolHandlerCustomizer",
|
||||
TomcatProtocolHandlerCustomizer.class);
|
||||
assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any());
|
||||
then(customizer).should().customize(any());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -211,7 +210,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
TomcatProtocolHandlerCustomizer<?> customizer = context.getBean("protocolHandlerCustomizer",
|
||||
TomcatProtocolHandlerCustomizer.class);
|
||||
assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any());
|
||||
then(customizer).should().customize(any());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -238,7 +237,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
JettyReactiveWebServerFactory factory = context.getBean(JettyReactiveWebServerFactory.class);
|
||||
JettyServerCustomizer customizer = context.getBean("serverCustomizer", JettyServerCustomizer.class);
|
||||
assertThat(factory.getServerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Server.class));
|
||||
then(customizer).should().customize(any(Server.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -266,7 +265,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer",
|
||||
UndertowBuilderCustomizer.class);
|
||||
assertThat(factory.getBuilderCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Builder.class));
|
||||
then(customizer).should().customize(any(Builder.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -293,7 +292,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
NettyReactiveWebServerFactory factory = context.getBean(NettyReactiveWebServerFactory.class);
|
||||
NettyServerCustomizer customizer = context.getBean("serverCustomizer", NettyServerCustomizer.class);
|
||||
assertThat(factory.getServerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).apply(any(HttpServer.class));
|
||||
then(customizer).should().apply(any(HttpServer.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -28,8 +28,8 @@ import org.springframework.boot.web.server.Shutdown;
|
||||
import org.springframework.boot.web.server.Ssl;
|
||||
|
||||
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 ReactiveWebServerFactoryCustomizer}.
|
||||
@@ -53,7 +53,7 @@ class ReactiveWebServerFactoryCustomizerTests {
|
||||
ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class);
|
||||
this.properties.setPort(9000);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setPort(9000);
|
||||
then(factory).should().setPort(9000);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,7 +62,7 @@ class ReactiveWebServerFactoryCustomizerTests {
|
||||
InetAddress address = mock(InetAddress.class);
|
||||
this.properties.setAddress(address);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setAddress(address);
|
||||
then(factory).should().setAddress(address);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +71,7 @@ class ReactiveWebServerFactoryCustomizerTests {
|
||||
Ssl ssl = mock(Ssl.class);
|
||||
this.properties.setSsl(ssl);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setSsl(ssl);
|
||||
then(factory).should().setSsl(ssl);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +80,7 @@ class ReactiveWebServerFactoryCustomizerTests {
|
||||
ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
ArgumentCaptor<Shutdown> shutdownCaptor = ArgumentCaptor.forClass(Shutdown.class);
|
||||
verify(factory).setShutdown(shutdownCaptor.capture());
|
||||
then(factory).should().setShutdown(shutdownCaptor.capture());
|
||||
assertThat(shutdownCaptor.getValue()).isEqualTo(Shutdown.GRACEFUL);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ import org.springframework.web.util.pattern.PathPattern;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link WebFluxAutoConfiguration}.
|
||||
@@ -154,7 +154,7 @@ class WebFluxAutoConfigurationTests {
|
||||
this.contextRunner.withUserConfiguration(CustomCodecCustomizers.class).run((context) -> {
|
||||
CodecCustomizer codecCustomizer = context.getBean("firstCodecCustomizer", CodecCustomizer.class);
|
||||
assertThat(codecCustomizer).isNotNull();
|
||||
verify(codecCustomizer).customize(any(ServerCodecConfigurer.class));
|
||||
then(codecCustomizer).should().customize(any(ServerCodecConfigurer.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -34,9 +34,8 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ClientHttpConnectorAutoConfiguration}
|
||||
@@ -94,7 +93,7 @@ class ClientHttpConnectorAutoConfigurationTests {
|
||||
WebClientCustomizer clientCustomizer = context.getBean(WebClientCustomizer.class);
|
||||
WebClient.Builder builder = mock(WebClient.Builder.class);
|
||||
clientCustomizer.customize(builder);
|
||||
verify(builder, times(1)).clientConnector(any(ReactorClientHttpConnector.class));
|
||||
then(builder).should().clientConnector(any(ReactorClientHttpConnector.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,7 +105,7 @@ class ClientHttpConnectorAutoConfigurationTests {
|
||||
WebClientCustomizer clientCustomizer = context.getBean(WebClientCustomizer.class);
|
||||
WebClient.Builder builder = mock(WebClient.Builder.class);
|
||||
clientCustomizer.customize(builder);
|
||||
verify(builder, times(1)).clientConnector(any(ClientHttpConnector.class));
|
||||
then(builder).should().clientConnector(any(ClientHttpConnector.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -40,9 +40,9 @@ 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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link WebClientAutoConfiguration}
|
||||
@@ -71,7 +71,7 @@ class WebClientAutoConfigurationTests {
|
||||
WebClientCodecCustomizer clientCustomizer = context.getBean(WebClientCodecCustomizer.class);
|
||||
builder.build();
|
||||
assertThat(clientCustomizer).isNotNull();
|
||||
verify(codecCustomizer).customize(any(CodecConfigurer.class));
|
||||
then(codecCustomizer).should().customize(any(CodecConfigurer.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class WebClientAutoConfigurationTests {
|
||||
WebClient.Builder builder = context.getBean(WebClient.Builder.class);
|
||||
WebClientCustomizer customizer = context.getBean("webClientCustomizer", WebClientCustomizer.class);
|
||||
builder.build();
|
||||
verify(customizer).customize(any(WebClient.Builder.class));
|
||||
then(customizer).should().customize(any(WebClient.Builder.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,11 +102,12 @@ class WebClientAutoConfigurationTests {
|
||||
assertThat(firstBuilder).isNotEqualTo(secondBuilder);
|
||||
firstBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
secondBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
verify(firstConnector).connect(eq(HttpMethod.GET), eq(URI.create("https://first.example.org/foo")), any());
|
||||
verify(secondConnector).connect(eq(HttpMethod.GET), eq(URI.create("https://second.example.org/foo")),
|
||||
then(firstConnector).should().connect(eq(HttpMethod.GET), eq(URI.create("https://first.example.org/foo")),
|
||||
any());
|
||||
then(secondConnector).should().connect(eq(HttpMethod.GET), eq(URI.create("https://second.example.org/foo")),
|
||||
any());
|
||||
WebClientCustomizer customizer = context.getBean("webClientCustomizer", WebClientCustomizer.class);
|
||||
verify(customizer, times(2)).customize(any(WebClient.Builder.class));
|
||||
then(customizer).should(times(2)).customize(any(WebClient.Builder.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -65,9 +65,8 @@ import org.springframework.web.servlet.FrameworkServlet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ServletWebServerFactoryAutoConfiguration}.
|
||||
@@ -178,7 +177,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
JettyServletWebServerFactory factory = context.getBean(JettyServletWebServerFactory.class);
|
||||
JettyServerCustomizer customizer = context.getBean("serverCustomizer", JettyServerCustomizer.class);
|
||||
assertThat(factory.getServerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Server.class));
|
||||
then(customizer).should().customize(any(Server.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -209,7 +208,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
UndertowDeploymentInfoCustomizer customizer = context.getBean("deploymentInfoCustomizer",
|
||||
UndertowDeploymentInfoCustomizer.class);
|
||||
assertThat(factory.getDeploymentInfoCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(DeploymentInfo.class));
|
||||
then(customizer).should().customize(any(DeploymentInfo.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -226,7 +225,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer",
|
||||
UndertowBuilderCustomizer.class);
|
||||
assertThat(factory.getBuilderCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Builder.class));
|
||||
then(customizer).should().customize(any(Builder.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -267,7 +266,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer",
|
||||
TomcatConnectorCustomizer.class);
|
||||
assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Connector.class));
|
||||
then(customizer).should().customize(any(Connector.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -283,7 +282,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer",
|
||||
TomcatConnectorCustomizer.class);
|
||||
assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Connector.class));
|
||||
then(customizer).should().customize(any(Connector.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -298,7 +297,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
|
||||
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
|
||||
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Context.class));
|
||||
then(customizer).should().customize(any(Context.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -313,7 +312,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
|
||||
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
|
||||
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any(Context.class));
|
||||
then(customizer).should().customize(any(Context.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -329,7 +328,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
TomcatProtocolHandlerCustomizer<?> customizer = context.getBean("protocolHandlerCustomizer",
|
||||
TomcatProtocolHandlerCustomizer.class);
|
||||
assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any());
|
||||
then(customizer).should().customize(any());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -345,7 +344,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
TomcatProtocolHandlerCustomizer<?> customizer = context.getBean("protocolHandlerCustomizer",
|
||||
TomcatProtocolHandlerCustomizer.class);
|
||||
assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer);
|
||||
verify(customizer, times(1)).customize(any());
|
||||
then(customizer).should().customize(any());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -387,7 +386,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
MockServletWebServerFactory factory = context.getBean(MockServletWebServerFactory.class);
|
||||
Servlet servlet = context.getBean(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME,
|
||||
Servlet.class);
|
||||
verify(factory.getServletContext()).addServlet("dispatcherServlet", servlet);
|
||||
then(factory.getServletContext()).should().addServlet("dispatcherServlet", servlet);
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -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.
|
||||
@@ -38,8 +38,8 @@ import org.springframework.boot.web.servlet.server.Session.Cookie;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ServletWebServerFactoryCustomizer}.
|
||||
@@ -62,7 +62,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
void testDefaultDisplayName() {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setDisplayName("application");
|
||||
then(factory).should().setDisplayName("application");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,7 +70,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.properties.getServlet().setApplicationDisplayName("TestName");
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setDisplayName("TestName");
|
||||
then(factory).should().setDisplayName("TestName");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +78,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.properties.getServlet().setRegisterDefaultServlet(false);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setRegisterDefaultServlet(false);
|
||||
then(factory).should().setRegisterDefaultServlet(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,14 +87,14 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
Ssl ssl = mock(Ssl.class);
|
||||
this.properties.setSsl(ssl);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setSsl(ssl);
|
||||
then(factory).should().setSsl(ssl);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomizeJsp() {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setJsp(any(Jsp.class));
|
||||
then(factory).should().setJsp(any(Jsp.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +113,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
ArgumentCaptor<Session> sessionCaptor = ArgumentCaptor.forClass(Session.class);
|
||||
verify(factory).setSession(sessionCaptor.capture());
|
||||
then(factory).should().setSession(sessionCaptor.capture());
|
||||
assertThat(sessionCaptor.getValue().getTimeout()).hasSeconds(123);
|
||||
Cookie cookie = sessionCaptor.getValue().getCookie();
|
||||
assertThat(cookie.getName()).isEqualTo("testname");
|
||||
@@ -129,7 +129,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.properties.setPort(8080);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setPort(8080);
|
||||
then(factory).should().setPort(8080);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +139,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setDisplayName("MyBootApp");
|
||||
then(factory).should().setDisplayName("MyBootApp");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,7 +158,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
ArgumentCaptor<Session> sessionCaptor = ArgumentCaptor.forClass(Session.class);
|
||||
verify(factory).setSession(sessionCaptor.capture());
|
||||
then(factory).should().setSession(sessionCaptor.capture());
|
||||
assertThat(sessionCaptor.getValue().getStoreDir()).isEqualTo(new File("mydirectory"));
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ class ServletWebServerFactoryCustomizerTests {
|
||||
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
ArgumentCaptor<Shutdown> shutdownCaptor = ArgumentCaptor.forClass(Shutdown.class);
|
||||
verify(factory).setShutdown(shutdownCaptor.capture());
|
||||
then(factory).should().setShutdown(shutdownCaptor.capture());
|
||||
assertThat(shutdownCaptor.getValue()).isEqualTo(Shutdown.GRACEFUL);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -32,8 +32,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link WebServer}s driving {@link ServletContextListener}s correctly
|
||||
@@ -77,7 +77,7 @@ class ServletWebServerServletContextListenerTests {
|
||||
ServletContextListenerBeanConfiguration.class, configuration);
|
||||
ServletContextListener servletContextListener = context.getBean("servletContextListener",
|
||||
ServletContextListener.class);
|
||||
verify(servletContextListener).contextInitialized(any(ServletContextEvent.class));
|
||||
then(servletContextListener).should().contextInitialized(any(ServletContextEvent.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class ServletWebServerServletContextListenerTests {
|
||||
ServletListenerRegistrationBeanConfiguration.class, configuration);
|
||||
ServletContextListener servletContextListener = (ServletContextListener) context
|
||||
.getBean("registration", ServletListenerRegistrationBean.class).getListener();
|
||||
verify(servletContextListener).contextInitialized(any(ServletContextEvent.class));
|
||||
then(servletContextListener).should().contextInitialized(any(ServletContextEvent.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -47,9 +47,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
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;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultErrorViewResolver}.
|
||||
@@ -108,9 +107,9 @@ class DefaultErrorViewResolverTests {
|
||||
ModelAndView resolved = this.resolver.resolveErrorView(this.request, HttpStatus.NOT_FOUND, this.model);
|
||||
assertThat(resolved).isNotNull();
|
||||
assertThat(resolved.getViewName()).isEqualTo("error/404");
|
||||
verify(this.templateAvailabilityProvider).isTemplateAvailable(eq("error/404"), any(Environment.class),
|
||||
then(this.templateAvailabilityProvider).should().isTemplateAvailable(eq("error/404"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class));
|
||||
verifyNoMoreInteractions(this.templateAvailabilityProvider);
|
||||
then(this.templateAvailabilityProvider).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,7 +176,7 @@ class DefaultErrorViewResolverTests {
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/404"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(false);
|
||||
ModelAndView resolved = this.resolver.resolveErrorView(this.request, HttpStatus.NOT_FOUND, this.model);
|
||||
verifyNoMoreInteractions(this.templateAvailabilityProvider);
|
||||
then(this.templateAvailabilityProvider).shouldHaveNoMoreInteractions();
|
||||
MockHttpServletResponse response = render(resolved);
|
||||
assertThat(response.getContentAsString().trim()).isEqualTo("exact/404");
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.TEXT_HTML_VALUE);
|
||||
|
||||
Reference in New Issue
Block a user