@Test public void nettyHttpClientDefaults() { new ReactiveWebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class, MetricsAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class, GatewayAutoConfiguration.class)) .withPropertyValues("debug=true") .run(context -> { assertThat(context).hasSingleBean(HttpClient.class); HttpClient httpClient = context.getBean(HttpClient.class); /*FIXME: 2.1.0 HttpClientOptions options = httpClient.options(); PoolResources poolResources = options.getPoolResources(); assertThat(poolResources).isNotNull(); //TODO: howto test PoolResources ClientProxyOptions proxyOptions = options.getProxyOptions(); assertThat(proxyOptions).isNull(); SslContext sslContext = options.sslContext(); assertThat(sslContext).isNull();*/ }); }
"spring.cloud.gateway.httpclient.pool.type=fixed", "spring.cloud.gateway.httpclient.proxy.host=myhost") .run(context -> { assertThat(context).hasSingleBean(HttpClient.class); HttpClient httpClient = context.getBean(HttpClient.class);
@Test public void apiVersionBeansAreNotCreatedWithoutServiceBeans() { webApplicationContextRunner() .run((context) -> { assertThat(context).doesNotHaveBean(BrokerApiVersion.class); assertThat(context).doesNotHaveBean(ApiVersionWebFilter.class); }); }
@Test public void controllersAreNotCreatedWithoutRequiredServices() { webApplicationContextRunner() .run(context -> assertThat(context.getStartupFailure()) .isExactlyInstanceOf(UnsatisfiedDependencyException.class)); }
@Test public void controllersAreCreated() { webApplicationContextRunner() .withUserConfiguration(FullServicesConfiguration.class) .run((context) -> { assertThat(context).hasSingleBean(CatalogController.class); assertThat(context).hasSingleBean(ServiceInstanceController.class); assertThat(context).hasSingleBean(ServiceInstanceBindingController.class); }); }
@Test public void apiVersionBeansAreCreatedWithCustomVersion() { webApplicationContextRunner() .withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromBean.class) .run((context) -> { assertThat(context).getBean(BrokerApiVersion.class) .hasFieldOrPropertyWithValue("apiVersion", API_VERSION_CURRENT); assertThat(context).hasSingleBean(ApiVersionWebFilter.class); }); }
@Test public void apiVersionBeansAreCreatedWithDefault() { webApplicationContextRunner() .withUserConfiguration(ServicesConfiguration.class) .run((context) -> { assertThat(context).getBean(BrokerApiVersion.class) .hasFieldOrPropertyWithValue("apiVersion", API_VERSION_ANY); assertThat(context).hasSingleBean(ApiVersionWebFilter.class); }); }
@Test public void apiVersionBeansAreCreatedFromCustomVersionProperty() { webApplicationContextRunner() .withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromProperty.class) .run((context) -> { assertThat(context).getBean(BrokerApiVersion.class) .hasFieldOrPropertyWithValue("apiVersion", "42.321"); assertThat(context).hasSingleBean(ApiVersionWebFilter.class); }); }
@Test public void apiVersionCheckIsDisabled() { webApplicationContextRunner() .withUserConfiguration(ServicesConfiguration.class) .withPropertyValues("spring.cloud.openservicebroker.api-version-check-enabled=false") .run((context) -> { assertThat(context).doesNotHaveBean(BrokerApiVersion.class); assertThat(context).doesNotHaveBean(ApiVersionWebFilter.class); }); }
@Test public void apiVersionBeansAreCreatedFromCustomVersionBeanOverridesProperty() { webApplicationContextRunner() .withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromBeanAndProperty.class) .run((context) -> { assertThat(context).getBean(BrokerApiVersion.class) .hasFieldOrPropertyWithValue("apiVersion", "99.999"); assertThat(context).hasSingleBean(ApiVersionWebFilter.class); }); }