Skip to content

Commit 41e652d

Browse files
committed
➖ Removed dependency on Spring RestClient
The testing classpath used to include the Spring classes which triggered the Spring autoconfiguration code (which, in turn, required that we mock out some of the classes provided by Spring that were used by the spring mvc autoconfiguration). Now that the testing classes no longer include those dependencies, we don't need to mock them.
1 parent 808b143 commit 41e652d

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

spring/fluentforms-jersey-spring-boot-autoconfigure/src/test/java/com/_4point/aem/fluentforms/spring/JerseyAutoConfigurationTest.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
import static org.junit.jupiter.api.Assertions.*;
55

66
import org.junit.jupiter.api.Test;
7-
import org.mockito.Mockito;
87
import org.springframework.boot.autoconfigure.AutoConfigurations;
9-
import org.springframework.boot.restclient.autoconfigure.RestClientSsl;
108
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
119
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
1210
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
1311
import org.springframework.boot.test.context.runner.ContextConsumer;
1412
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
15-
import org.springframework.context.annotation.Bean;
16-
import org.springframework.web.client.RestClient;
1713

1814
import com._4point.aem.fluentforms.api.output.OutputService;
1915
import com._4point.aem.fluentforms.spring.AemProxyAfSubmission.AfSubmissionHandler;
@@ -30,25 +26,11 @@
3026
*/
3127
class JerseyAutoConfigurationTest {
3228

33-
/**
34-
* This class provides mock versions of beans that would normally be provided by Spring Boot in a real application. We
35-
* only need to mock out the RestClient.Builder and RestClientSsl beans because those are the only Spring Boot provided
36-
* beans that our AutoConfigurations depend on.
37-
*
38-
* In theory, we should not need to provide these however spring-boot-starter-jersey brings in spring-boot-restclient
39-
* on to the test classpath which, in turn, triggers the inclusion of the fluent-forms springRestClientFactory which
40-
* requires the mocks.
41-
*/
42-
private static class SpringBootMocks {
43-
@Bean RestClient.Builder mockRestClientBuilder() { return Mockito.mock(RestClient.Builder.class, Mockito.RETURNS_DEEP_STUBS); }
44-
@Bean private RestClientSsl mockRestClientSsl() { return Mockito.mock(RestClientSsl.class); }
45-
}
46-
47-
private static final AutoConfigurations AUTO_CONFIG = AutoConfigurations.of(FluentFormsJerseyAutoConfiguration.class, AemProxyJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class, SpringBootMocks.class);
29+
private static final AutoConfigurations AUTO_CONFIG = AutoConfigurations.of(FluentFormsJerseyAutoConfiguration.class, AemProxyJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class);
4830

49-
private static final AutoConfigurations LOCAL_SUBMIT_CONFIG = AutoConfigurations.of(FluentFormsJerseyAutoConfiguration.class, AemProxyJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class, DummyLocalSubmitHandler.class, SpringBootMocks.class);
31+
private static final AutoConfigurations LOCAL_SUBMIT_CONFIG = AutoConfigurations.of(FluentFormsJerseyAutoConfiguration.class, AemProxyJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class, DummyLocalSubmitHandler.class);
5032

51-
private static final AutoConfigurations ALTERNATE_PROXY_CONFIG = AutoConfigurations.of(DummyProxyImplementation.class, FluentFormsJerseyAutoConfiguration.class, AemProxyJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class, SpringBootMocks.class);
33+
private static final AutoConfigurations ALTERNATE_PROXY_CONFIG = AutoConfigurations.of(DummyProxyImplementation.class, FluentFormsJerseyAutoConfiguration.class, AemProxyJerseyAutoConfiguration.class, FluentFormsAutoConfiguration.class);
5234

5335
// Tests to make sure that only the FluentFormsLibraries are loaded in a non-web application.
5436
private static final ContextConsumer<? super AssertableApplicationContext> FF_LIBRARIES_ONLY = (context) -> {

0 commit comments

Comments
 (0)