Polishing
This commit is contained in:
parent
0fc3e3d166
commit
5616915621
|
|
@ -62,8 +62,7 @@ public class ElasticsearchAutoConfigurationTests {
|
|||
PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeanNamesForType(Client.class).length)
|
||||
.isEqualTo(1);
|
||||
assertThat(this.context.getBeanNamesForType(Client.class).length).isEqualTo(1);
|
||||
assertThat(this.context.getBean("myClient"))
|
||||
.isSameAs(this.context.getBean(Client.class));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ public class Neo4jDataAutoConfigurationTests {
|
|||
public void defaultConfiguration() {
|
||||
this.context.withPropertyValues("spring.data.neo4j.uri=http://localhost:8989")
|
||||
.run((loaded) -> {
|
||||
assertThat(loaded).hasSingleBean(
|
||||
org.neo4j.ogm.config.Configuration.class);
|
||||
assertThat(loaded)
|
||||
.hasSingleBean(org.neo4j.ogm.config.Configuration.class);
|
||||
assertThat(loaded).hasSingleBean(SessionFactory.class);
|
||||
assertThat(loaded).hasSingleBean(Neo4jTransactionManager.class);
|
||||
assertThat(loaded).hasSingleBean(OpenSessionInViewInterceptor.class);
|
||||
|
|
@ -73,13 +73,15 @@ public class Neo4jDataAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void customNeo4jTransactionManagerUsingProperties() {
|
||||
this.context.withPropertyValues("spring.transaction.default-timeout=30",
|
||||
"spring.transaction.rollback-on-commit-failure:true").run((loaded) -> {
|
||||
Neo4jTransactionManager transactionManager = loaded
|
||||
.getBean(Neo4jTransactionManager.class);
|
||||
assertThat(transactionManager.getDefaultTimeout()).isEqualTo(30);
|
||||
assertThat(transactionManager.isRollbackOnCommitFailure()).isTrue();
|
||||
});
|
||||
this.context
|
||||
.withPropertyValues("spring.transaction.default-timeout=30",
|
||||
"spring.transaction.rollback-on-commit-failure:true")
|
||||
.run((loaded) -> {
|
||||
Neo4jTransactionManager transactionManager = loaded
|
||||
.getBean(Neo4jTransactionManager.class);
|
||||
assertThat(transactionManager.getDefaultTimeout()).isEqualTo(30);
|
||||
assertThat(transactionManager.isRollbackOnCommitFailure()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -121,8 +123,8 @@ public class Neo4jDataAutoConfigurationTests {
|
|||
@Test
|
||||
public void openSessionInViewInterceptorCanBeDisabled() {
|
||||
this.context.withPropertyValues("spring.data.neo4j.open-in-view:false")
|
||||
.run((loaded) -> assertThat(loaded).doesNotHaveBean(
|
||||
OpenSessionInViewInterceptor.class));
|
||||
.run((loaded) -> assertThat(loaded)
|
||||
.doesNotHaveBean(OpenSessionInViewInterceptor.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -130,7 +132,8 @@ public class Neo4jDataAutoConfigurationTests {
|
|||
this.context.withUserConfiguration(EventListenerConfiguration.class)
|
||||
.run((loaded) -> {
|
||||
Session session = loaded.getBean(SessionFactory.class).openSession();
|
||||
session.notifyListeners(new PersistenceEvent(null, Event.TYPE.PRE_SAVE));
|
||||
session.notifyListeners(
|
||||
new PersistenceEvent(null, Event.TYPE.PRE_SAVE));
|
||||
verify(loaded.getBean("eventListenerOne", EventListener.class))
|
||||
.onPreSave(any(Event.class));
|
||||
verify(loaded.getBean("eventListenerTwo", EventListener.class))
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class HazelcastAutoConfigurationClientTests {
|
|||
}
|
||||
|
||||
private Condition<HazelcastInstance> nameStartingWith(String prefix) {
|
||||
return new Condition<HazelcastInstance>((o) -> o.getName().startsWith(prefix),
|
||||
return new Condition<>((o) -> o.getName().startsWith(prefix),
|
||||
"Name starts with " + prefix);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,16 +46,17 @@ public class InfluxDbAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void influxDbRequiresUrl() {
|
||||
this.context.run((loaded) ->
|
||||
assertThat(loaded.getBeansOfType(InfluxDB.class)).isEmpty());
|
||||
this.context.run(
|
||||
(loaded) -> assertThat(loaded.getBeansOfType(InfluxDB.class)).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void influxDbCanBeCustomized() {
|
||||
this.context.withPropertyValues("spring.influx.url=http://localhost",
|
||||
"spring.influx.password:password", "spring.influx.user:user")
|
||||
.run((loaded ->
|
||||
assertThat(loaded.getBeansOfType(InfluxDB.class)).hasSize(1)));
|
||||
this.context
|
||||
.withPropertyValues("spring.influx.url=http://localhost",
|
||||
"spring.influx.password:password", "spring.influx.user:user")
|
||||
.run((loaded -> assertThat(loaded.getBeansOfType(InfluxDB.class))
|
||||
.hasSize(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -71,11 +72,12 @@ public class InfluxDbAutoConfigurationTests {
|
|||
@Test
|
||||
public void influxDbWithoutCredentialsAndOkHttpClientBuilder() {
|
||||
this.context.withUserConfiguration(CustomOkHttpClientBuilderConfig.class)
|
||||
.withPropertyValues("spring.influx.url=http://localhost").run((loaded) -> {
|
||||
assertThat(loaded.getBeansOfType(InfluxDB.class)).hasSize(1);
|
||||
int readTimeout = getReadTimeoutProperty(loaded);
|
||||
assertThat(readTimeout).isEqualTo(30_000);
|
||||
});
|
||||
.withPropertyValues("spring.influx.url=http://localhost")
|
||||
.run((loaded) -> {
|
||||
assertThat(loaded.getBeansOfType(InfluxDB.class)).hasSize(1);
|
||||
int readTimeout = getReadTimeoutProperty(loaded);
|
||||
assertThat(readTimeout).isEqualTo(30_000);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -126,8 +126,7 @@ public class KafkaAutoConfigurationTests {
|
|||
public void producerProperties() {
|
||||
load("spring.kafka.clientId=cid",
|
||||
"spring.kafka.properties.foo.bar.baz=qux.fiz.buz",
|
||||
"spring.kafka.producer.acks=all",
|
||||
"spring.kafka.producer.batch-size=20",
|
||||
"spring.kafka.producer.acks=all", "spring.kafka.producer.batch-size=20",
|
||||
"spring.kafka.producer.bootstrap-servers=bar:1234", // test override
|
||||
"spring.kafka.producer.buffer-memory=12345",
|
||||
"spring.kafka.producer.compression-type=gzip",
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ public class RemoteClientConfigurationTests {
|
|||
@Test
|
||||
public void warnIfRestartDisabled() throws Exception {
|
||||
configure("spring.devtools.remote.restart.enabled:false");
|
||||
assertThat(this.output.toString())
|
||||
.contains("Remote restart is disabled");
|
||||
assertThat(this.output.toString()).contains("Remote restart is disabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ class AssertProviderApplicationContextInvocationHandler implements InvocationHan
|
|||
}
|
||||
|
||||
private Object getAssertThat(Object proxy) {
|
||||
return new ApplicationContextAssert<ApplicationContext>(
|
||||
(ApplicationContext) proxy, this.startupFailure);
|
||||
return new ApplicationContextAssert<>((ApplicationContext) proxy,
|
||||
this.startupFailure);
|
||||
}
|
||||
|
||||
private boolean isCloseMethod(Method method) {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import java.net.URL;
|
|||
import java.net.URLClassLoader;
|
||||
|
||||
/**
|
||||
* Test {@link URLClassLoader} that hides configurable packages. No class
|
||||
* in one of those packages or sub-packages are visible.
|
||||
* Test {@link URLClassLoader} that hides configurable packages. No class in one of those
|
||||
* packages or sub-packages are visible.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ public class NoUnboundElementsBindHandler extends AbstractBindHandler {
|
|||
this(parent, (configurationPropertySource) -> true);
|
||||
}
|
||||
|
||||
public NoUnboundElementsBindHandler(BindHandler parent, Function<ConfigurationPropertySource, Boolean> filter) {
|
||||
public NoUnboundElementsBindHandler(BindHandler parent,
|
||||
Function<ConfigurationPropertySource, Boolean> filter) {
|
||||
super(parent);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
|
@ -77,7 +78,8 @@ public class NoUnboundElementsBindHandler extends AbstractBindHandler {
|
|||
BindContext context) {
|
||||
Set<ConfigurationProperty> unbound = new TreeSet<>();
|
||||
for (ConfigurationPropertySource source : context.getSources()) {
|
||||
if (source instanceof IterableConfigurationPropertySource && this.filter.apply(source)) {
|
||||
if (source instanceof IterableConfigurationPropertySource
|
||||
&& this.filter.apply(source)) {
|
||||
collectUnbound(name, unbound,
|
||||
(IterableConfigurationPropertySource) source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,19 +26,21 @@ import org.springframework.core.env.PropertySource;
|
|||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
/**
|
||||
* Function used to determine if a {@link ConfigurationPropertySource} should be
|
||||
* included when determining unbound elements. If the underlying {@link PropertySource}
|
||||
* is a systemEnvironment or systemProperties property source, it will not be considered
|
||||
* for unbound element failures.
|
||||
* Function used to determine if a {@link ConfigurationPropertySource} should be included
|
||||
* when determining unbound elements. If the underlying {@link PropertySource} is a
|
||||
* systemEnvironment or systemProperties property source, it will not be considered for
|
||||
* unbound element failures.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class UnboundElementsSourceFilter implements Function<ConfigurationPropertySource, Boolean> {
|
||||
public class UnboundElementsSourceFilter
|
||||
implements Function<ConfigurationPropertySource, Boolean> {
|
||||
|
||||
private static final Set<String> BENIGN_PROPERTY_SOURCE_NAMES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
|
||||
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
|
||||
StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)));
|
||||
private static final Set<String> BENIGN_PROPERTY_SOURCE_NAMES = Collections
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList(
|
||||
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
|
||||
StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)));
|
||||
|
||||
@Override
|
||||
public Boolean apply(ConfigurationPropertySource configurationPropertySource) {
|
||||
|
|
@ -52,4 +54,3 @@ public class UnboundElementsSourceFilter implements Function<ConfigurationProper
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,8 +156,8 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a mutable collection of Jetty {@link JettyServerCustomizer}s that will be applied
|
||||
* to the {@link Server} before it is created.
|
||||
* Returns a mutable collection of Jetty {@link JettyServerCustomizer}s that will be
|
||||
* applied to the {@link Server} before it is created.
|
||||
* @return the Jetty customizers
|
||||
*/
|
||||
public Collection<JettyServerCustomizer> getServerCustomizers() {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
|
|||
|
||||
/**
|
||||
* Set {@link UndertowBuilderCustomizer}s that should be applied to the Undertow
|
||||
* {@link Undertow.Builder}. Calling this method will replace any existing customizers.
|
||||
* {@link Undertow.Builder}. Calling this method will replace any existing
|
||||
* customizers.
|
||||
* @param customizers the customizers to set
|
||||
*/
|
||||
public void setBuilderCustomizers(
|
||||
|
|
|
|||
|
|
@ -482,7 +482,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
|
|||
File docBase = getCanonicalDocumentRoot(root);
|
||||
List<URL> metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources();
|
||||
List<URL> resourceJarUrls = new ArrayList<>();
|
||||
List<ResourceManager> resourceManagers = new ArrayList<ResourceManager>();
|
||||
List<ResourceManager> resourceManagers = new ArrayList<>();
|
||||
ResourceManager rootResourceManager = docBase.isDirectory()
|
||||
? new FileResourceManager(docBase, 0) : new JarResourceManager(docBase);
|
||||
resourceManagers.add(root == null ? rootResourceManager
|
||||
|
|
|
|||
|
|
@ -44,15 +44,19 @@ public class UnboundElementsSourceFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void filterWhenSourceIsSystemEnvironmentPropertySourceShouldReturnFalse() throws Exception {
|
||||
MockPropertySource propertySource = new MockPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
public void filterWhenSourceIsSystemEnvironmentPropertySourceShouldReturnFalse()
|
||||
throws Exception {
|
||||
MockPropertySource propertySource = new MockPropertySource(
|
||||
StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
given(this.source.getUnderlyingSource()).willReturn(propertySource);
|
||||
assertThat(this.filter.apply(this.source)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWhenSourceIsSystemPropertiesPropertySourceShouldReturnTrue() throws Exception {
|
||||
MockPropertySource propertySource = new MockPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
|
||||
public void filterWhenSourceIsSystemPropertiesPropertySourceShouldReturnTrue()
|
||||
throws Exception {
|
||||
MockPropertySource propertySource = new MockPropertySource(
|
||||
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
|
||||
given(this.source.getUnderlyingSource()).willReturn(propertySource);
|
||||
assertThat(this.filter.apply(this.source)).isFalse();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue