Merge branch '2.7.x' into 3.0.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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,10 +34,13 @@ public class MyBean {
|
||||
// @fold:on // ...
|
||||
public String someMethod(String message) {
|
||||
try (Session session = this.driver.session()) {
|
||||
return session.executeWrite((transaction) -> transaction
|
||||
.run("CREATE (a:Greeting) SET a.message = $message RETURN a.message + ', from node ' + id(a)",
|
||||
Values.parameters("message", message))
|
||||
.single().get(0).asString());
|
||||
return session.executeWrite(
|
||||
(transaction) -> transaction
|
||||
.run("CREATE (a:Greeting) SET a.message = $message RETURN a.message + ', from node ' + id(a)",
|
||||
Values.parameters("message", message))
|
||||
.single()
|
||||
.get(0)
|
||||
.asString());
|
||||
}
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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,7 +30,7 @@ class MyServiceAutoConfigurationTests {
|
||||
|
||||
// tag::runner[]
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(MyServiceAutoConfiguration.class));
|
||||
.withConfiguration(AutoConfigurations.of(MyServiceAutoConfiguration.class));
|
||||
|
||||
// end::runner[]
|
||||
|
||||
@@ -48,7 +48,7 @@ class MyServiceAutoConfigurationTests {
|
||||
@Test
|
||||
void serviceIsIgnoredIfLibraryIsNotPresent() {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(MyService.class))
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("myService"));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("myService"));
|
||||
}
|
||||
// end::test-classloader[]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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,7 +36,7 @@ class MyJsonAssertJTests {
|
||||
void someTest() throws Exception {
|
||||
SomeObject value = new SomeObject(0.152f);
|
||||
assertThat(this.json.write(value)).extractingJsonPathNumberValue("@.test.numberValue")
|
||||
.satisfies((number) -> assertThat(number.floatValue()).isCloseTo(0.15f, within(0.01f)));
|
||||
.satisfies((number) -> assertThat(number.floatValue()).isCloseTo(0.15f, within(0.01f)));
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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,11 +30,13 @@ class GraphQlIntegrationTests {
|
||||
@Test
|
||||
void shouldGreetWithSpecificName(@Autowired HttpGraphQlTester graphQlTester) {
|
||||
HttpGraphQlTester authenticatedTester = graphQlTester.mutate()
|
||||
.webTestClient(
|
||||
(client) -> client.defaultHeaders((headers) -> headers.setBasicAuth("admin", "ilovespring")))
|
||||
.build();
|
||||
authenticatedTester.document("{ greeting(name: \"Alice\") } ").execute().path("greeting").entity(String.class)
|
||||
.isEqualTo("Hello, Alice!");
|
||||
.webTestClient((client) -> client.defaultHeaders((headers) -> headers.setBasicAuth("admin", "ilovespring")))
|
||||
.build();
|
||||
authenticatedTester.document("{ greeting(name: \"Alice\") } ")
|
||||
.execute()
|
||||
.path("greeting")
|
||||
.entity(String.class)
|
||||
.isEqualTo("Hello, Alice!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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,14 +31,20 @@ class GreetingControllerTests {
|
||||
|
||||
@Test
|
||||
void shouldGreetWithSpecificName() {
|
||||
this.graphQlTester.document("{ greeting(name: \"Alice\") } ").execute().path("greeting").entity(String.class)
|
||||
.isEqualTo("Hello, Alice!");
|
||||
this.graphQlTester.document("{ greeting(name: \"Alice\") } ")
|
||||
.execute()
|
||||
.path("greeting")
|
||||
.entity(String.class)
|
||||
.isEqualTo("Hello, Alice!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldGreetWithDefaultName() {
|
||||
this.graphQlTester.document("{ greeting } ").execute().path("greeting").entity(String.class)
|
||||
.isEqualTo("Hello, Spring!");
|
||||
this.graphQlTester.document("{ greeting } ")
|
||||
.execute()
|
||||
.path("greeting")
|
||||
.entity(String.class)
|
||||
.isEqualTo("Hello, Spring!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ class MySpringBootTests {
|
||||
@Bean
|
||||
RestTemplateBuilder restTemplateBuilder() {
|
||||
return new RestTemplateBuilder().setConnectTimeout(Duration.ofSeconds(1))
|
||||
.setReadTimeout(Duration.ofSeconds(1));
|
||||
.setReadTimeout(Duration.ofSeconds(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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,9 @@ public class MyRestTemplateBuilderConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestTemplateBuilder restTemplateBuilder(RestTemplateBuilderConfigurer configurer) {
|
||||
return configurer.configure(new RestTemplateBuilder()).setConnectTimeout(Duration.ofSeconds(5))
|
||||
.setReadTimeout(Duration.ofSeconds(2));
|
||||
return configurer.configure(new RestTemplateBuilder())
|
||||
.setConnectTimeout(Duration.ofSeconds(5))
|
||||
.setReadTimeout(Duration.ofSeconds(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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,8 +40,8 @@ public class MyConfiguration__BeanDefinitions {
|
||||
* Get the bean instance supplier for 'myBean'.
|
||||
*/
|
||||
private static BeanInstanceSupplier<MyBean> getMyBeanInstanceSupplier() {
|
||||
return BeanInstanceSupplier.<MyBean>forFactoryMethod(MyConfiguration.class, "myBean").withGenerator(
|
||||
(registeredBean) -> registeredBean.getBeanFactory().getBean(MyConfiguration.class).myBean());
|
||||
return BeanInstanceSupplier.<MyBean>forFactoryMethod(MyConfiguration.class, "myBean")
|
||||
.withGenerator((registeredBean) -> registeredBean.getBeanFactory().getBean(MyConfiguration.class).myBean());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,8 @@ public class RSocketGraphQlClientExample {
|
||||
public void rsocketOverTcp() {
|
||||
// tag::request[]
|
||||
Mono<Book> book = this.graphQlClient.document("{ bookById(id: \"book-1\"){ id name pageCount author } }")
|
||||
.retrieve("bookById").toEntity(Book.class);
|
||||
.retrieve("bookById")
|
||||
.toEntity(Book.class);
|
||||
// end::request[]
|
||||
book.block(Duration.ofSeconds(5));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -29,7 +29,7 @@ public class MySamlRelyingPartyConfiguration {
|
||||
http.authorizeHttpRequests().anyRequest().authenticated();
|
||||
http.saml2Login();
|
||||
http.saml2Logout((saml2) -> saml2.logoutRequest((request) -> request.logoutUrl("/SLOService.saml2"))
|
||||
.logoutResponse((response) -> response.logoutUrl("/SLOService.saml2")));
|
||||
.logoutResponse((response) -> response.logoutUrl("/SLOService.saml2")));
|
||||
return http.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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,33 +36,33 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class MyPropertiesTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(Config.class);
|
||||
.withUserConfiguration(Config.class);
|
||||
|
||||
@Test
|
||||
void bindWithDefaultUnit() {
|
||||
this.contextRunner.withPropertyValues("my.session-timeout=40", "my.read-timeout=5000")
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(40);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(40);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindWithExplicitUnit() {
|
||||
this.contextRunner.withPropertyValues("my.session-timeout=1h", "my.read-timeout=5s")
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasMinutes(60);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasMinutes(60);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindWithIso8601Format() {
|
||||
this.contextRunner.withPropertyValues("my.session-timeout=PT15S", "my.read-timeout=PT0.5S")
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(15);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(500);
|
||||
}));
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(15);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(500);
|
||||
}));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertBinding(Consumer<MyProperties> properties) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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,33 +36,33 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class MyPropertiesTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(Config.class);
|
||||
.withUserConfiguration(Config.class);
|
||||
|
||||
@Test
|
||||
void bindWithDefaultUnit() {
|
||||
this.contextRunner.withPropertyValues("my.session-timeout=40", "my.read-timeout=5000")
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(40);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(40);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindWithExplicitUnit() {
|
||||
this.contextRunner.withPropertyValues("my.session-timeout=1h", "my.read-timeout=5s")
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasMinutes(60);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasMinutes(60);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(5000);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindWithIso8601Format() {
|
||||
this.contextRunner.withPropertyValues("my.session-timeout=PT15S", "my.read-timeout=PT0.5S")
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(15);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(500);
|
||||
}));
|
||||
.run(assertBinding((properties) -> {
|
||||
assertThat(properties.getSessionTimeout()).hasSeconds(15);
|
||||
assertThat(properties.getReadTimeout()).hasMillis(500);
|
||||
}));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertBinding(Consumer<MyProperties> properties) {
|
||||
|
||||
Reference in New Issue
Block a user