closes #27747
Comment From: pivotal-cla
@brneto Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@brneto Thank you for signing the Contributor License Agreement!
Comment From: brneto
@wilkinsona It failed with message A build scan was not published as you have not authenticated with server 'ge.spring.io'.
, is there something more I have to do?
Comment From: wilkinsona
It failed with message A build scan was not published as you have not authenticated with server 'ge.spring.io'., is there something more I have to do?
That's not a failure. It's just indicating that it couldn't publish a build scan to ge.spring.io
. The build itself should be unaffected.
Comment From: brneto
I'm still intrigued why this doesn't work:
@WebFluxTest
@AutoConfigureRestDocs
abstract class ContractTest {
@TestConfiguration(proxyBeanMethods = false)
static class RestDocsParameterizedOutput {
@Bean
WebTestClientBuilderCustomizer restDocsParameterizedOutput() {
return builder -> builder.entityExchangeResultConsumer(document("{class-name}/{method-name}"));
}
}
@Autowired
private WebTestClient webTestClient;
void webTestClientSetup() {
RestAssuredWebTestClient.webTestClient(webTestClient);
}
}
While this does:
@WebFluxTest
@AutoConfigureRestDocs
abstract class ContractTest {
@Autowired
private ApplicationContext context;
@Autowired
private WebTestClientRestDocumentationConfigurer configurer;
void webTestClientSetup() {
RestAssuredWebTestClient.webTestClient(
WebTestClient
.bindToApplicationContext(context)
.configureClient()
.filter(configurer)
.entityExchangeResultConsumer(document("{class-name}/{method-name}"))
.build());
}
}
Any thought why this is happening?
Thanks!
Comment From: brneto
@wilkinsona I've just figured out why this is happening! That's because the tests generated by the Spring Contract Test does not have the @TestConfiguration
creating the WebTestClientBuilderCustomizer
bean. Would you have any suggestion how I could overcome this? Thanks!
Comment From: brneto
@wilkinsona It worked externalising the @TestConfiguration
class and importing it.
e.g.
@WebFluxTest
@AutoConfigureRestDocs
@Import(ContractTestConfiguration.class)
abstract class ContractTest {
@BeforeEach
void webTestClientSetup(@Autowired WebTestClient webTestClient) {
RestAssuredWebTestClient.webTestClient(webTestClient);
}
}
Comment From: brneto
@wilkinsona is there anything else I have to do or this is it for this PR?
Do you know why this concourse-ci/status
check is still in failure state?
Comment From: wilkinsona
It's failing because the code in MyWebTestClientBuilderCustomizerConfiguration
doesn't compile. It appears to be missing a static import for WebTestClientRestDocumentation.document
. The package declaration is also incorrect. Don't worry about it, though. We can take care of it when we come to merge this.
Comment From: brneto
Let me fix that. Give me a sec.
Comment From: brneto
@wilkinsona, just did ae79b33132568e44993660cb981c167823a7c131. Sorry for that! :(
Comment From: brneto
@wilkinsona it's still failing! Have I made any other mistake? :(
Comment From: scottfrederick
@brneto Just a small checkstyle violation. You can push another commit to fix that, or as Andy said we're happy to fix it when merging.
Comment From: brneto
@wilkinsona I'm migrating my project to Gradle and after that I start receiving this error message from my test:
java.lang.NoClassDefFoundError: org/springframework/restdocs/ManualRestDocumentation
at org.springframework.boot.test.autoconfigure.restdocs.RestDocumentationContextProviderRegistrar.registerBeanDefinitions(RestDocumentationContextProviderRegistrar.java:41)
at org.springframework.context.annotation.ImportBeanDefinitionRegistrar.registerBeanDefinitions(ImportBeanDefinitionRegistrar.java:86)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:396)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:723)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:395)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:157)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
Caused by:
java.lang.ClassNotFoundException: org.springframework.restdocs.ManualRestDocumentation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 79 more
I haven't change anything in code but still I having this error with qradle cleanTest test
. Any suggestion?
Comment From: wilkinsona
@brneto A Spring Boot pull request isn’t a good place to ask for some support with Spring REST Docs. Please ask on Stack Overflow or Gitter instead.
Comment From: wilkinsona
@brneto Thanks very much for making your first contribution to Spring Boot.