org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner Java Examples

The following examples show how to use org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GatewayRSocketAutoConfigurationTests.java    From spring-cloud-rsocket with Apache License 2.0 6 votes vote down vote up
@Test
public void gatewayRSocketConfigured() {
	new ReactiveWebApplicationContextRunner().withUserConfiguration(MyConfig.class)
			.withSystemProperties("spring.cloud.gateway.rsocket.route-id=11")
			.withConfiguration(
					AutoConfigurations.of(RSocketStrategiesAutoConfiguration.class,
							RSocketMessagingAutoConfiguration.class,
							GatewayRSocketCommonAutoConfiguration.class,
							GatewayRSocketAutoConfiguration.class,
							CompositeMeterRegistryAutoConfiguration.class,
							MetricsAutoConfiguration.class))
			.run(context -> assertThat(context).hasSingleBean(RoutingTable.class)
					.hasSingleBean(RoutingTableRoutes.class)
					.hasSingleBean(RoutingTableSocketAcceptorFilter.class)
					.hasSingleBean(GatewayServerRSocketFactoryProcessor.class)
					.hasSingleBean(BrokerProperties.class)
					.hasSingleBean(GatewaySocketAcceptor.class)
					.hasSingleBean(SocketAcceptorPredicateFilter.class)
					.hasSingleBean(RSocketServerBootstrap.class)
					.doesNotHaveBean(SocketAcceptorPredicate.class));
}
 
Example #2
Source File: GatewayAutoConfigurationTests.java    From spring-cloud-gateway with Apache License 2.0 6 votes vote down vote up
@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);
				assertThat(context).hasBean("gatewayHttpClient");
				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();
				 */
			});
}
 
Example #3
Source File: XsuaaResourceServerJwkAutoConfigurationTest.java    From cloud-security-xsuaa-integration with Apache License 2.0 5 votes vote down vote up
@Test
public void autoConfigurationDisabledWhenSpringReactorIsActive() {
	ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
			.withConfiguration(
					AutoConfigurations.of(XsuaaResourceServerJwkAutoConfiguration.class,
							XsuaaAutoConfiguration.class));

	contextRunner.run((context) -> {
		assertThat(context.containsBean("xsuaaJwtDecoder"), is(false));
	});
}
 
Example #4
Source File: CredHubOAuth2AutoConfigurationTests.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
@Test
public void oauth2ContextConfiguredWithReactiveWebApp() {
	new ReactiveWebApplicationContextRunner().withConfiguration(AutoConfigurations.of(this.configurations))
			.withPropertyValues(this.oAuth2ClientProperties).run((context) -> {
				assertServletOAuth2ContextConfigured(context);
				assertReactiveOAuth2ContextConfigured(context);
			});
}
 
Example #5
Source File: CredHubOAuth2AutoConfigurationTests.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
@Test
public void oauth2ContextConfiguredWithReactiveWebAppNoServlet() {
	new ReactiveWebApplicationContextRunner().withClassLoader(new FilteredClassLoader("javax.servlet"))
			.withConfiguration(AutoConfigurations.of(this.configurations))
			.withPropertyValues(this.oAuth2ClientProperties).run((context) -> {
				assertServletOAuth2ContextNotConfigured(context);
				assertReactiveOAuth2ContextConfigured(context);
			});
}
 
Example #6
Source File: StackdriverLoggingAutoConfigurationTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonServletConfiguration() {
	new ReactiveWebApplicationContextRunner().withConfiguration(
			AutoConfigurations.of(
					StackdriverLoggingAutoConfiguration.class,
					GcpContextAutoConfiguration.class))
			.run((context) -> assertThat(context
					.getBeansOfType(TraceIdLoggingWebMvcInterceptor.class).size())
							.isEqualTo(0));
}
 
Example #7
Source File: SpringBootAdminClientAutoConfigurationTest.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
@Test
public void reactiveEnvironment() {
	ReactiveWebApplicationContextRunner reactiveContextRunner = new ReactiveWebApplicationContextRunner()
			.withConfiguration(
					AutoConfigurations.of(EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class,
							WebClientAutoConfiguration.class, SpringBootAdminClientAutoConfiguration.class));
	reactiveContextRunner.withPropertyValues("spring.boot.admin.client.url:http://localhost:8081")
			.run((context) -> assertThat(context).hasSingleBean(ApplicationRegistrator.class));
}
 
Example #8
Source File: GatewayAutoConfigurationTests.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
@Test
public void nettyHttpClientConfigured() {
	new ReactiveWebApplicationContextRunner()
			.withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class,
					MetricsAutoConfiguration.class,
					SimpleMetricsExportAutoConfiguration.class,
					GatewayAutoConfiguration.class, HttpClientCustomizedConfig.class))
			.withPropertyValues(
					"spring.cloud.gateway.httpclient.ssl.use-insecure-trust-manager=true",
					"spring.cloud.gateway.httpclient.connect-timeout=10",
					"spring.cloud.gateway.httpclient.response-timeout=10s",
					"spring.cloud.gateway.httpclient.pool.type=fixed",
					// greather than integer max value
					"spring.cloud.gateway.httpclient.max-initial-line-length=2147483647",
					"spring.cloud.gateway.httpclient.proxy.host=myhost",
					"spring.cloud.gateway.httpclient.websocket.max-frame-payload-length=1024")
			.run(context -> {
				assertThat(context).hasSingleBean(HttpClient.class);
				HttpClient httpClient = context.getBean(HttpClient.class);
				HttpClientProperties properties = context
						.getBean(HttpClientProperties.class);
				assertThat(properties.getMaxInitialLineLength().toBytes())
						.isLessThanOrEqualTo(Integer.MAX_VALUE);
				/*
				 * 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).isNotNull();
				 * assertThat(proxyOptions.getAddress().get().getHostName()).isEqualTo
				 * ("myhost");
				 *
				 * SslContext sslContext = options.sslContext();
				 * assertThat(sslContext).isNotNull();
				 */
				// TODO: howto test SslContext
				assertThat(context)
						.hasSingleBean(ReactorNettyRequestUpgradeStrategy.class);
				ReactorNettyRequestUpgradeStrategy upgradeStrategy = context
						.getBean(ReactorNettyRequestUpgradeStrategy.class);
				assertThat(upgradeStrategy.getMaxFramePayloadLength())
						.isEqualTo(1024);
				assertThat(upgradeStrategy.getHandlePing()).isTrue();
				assertThat(context).hasSingleBean(ReactorNettyWebSocketClient.class);
				ReactorNettyWebSocketClient webSocketClient = context
						.getBean(ReactorNettyWebSocketClient.class);
				assertThat(webSocketClient.getMaxFramePayloadLength())
						.isEqualTo(1024);
				HttpClientCustomizedConfig config = context
						.getBean(HttpClientCustomizedConfig.class);
				assertThat(config.called.get()).isTrue();
			});
}
 
Example #9
Source File: ApiVersionWebFluxAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 4 votes vote down vote up
private ReactiveWebApplicationContextRunner webApplicationContextRunner() {
	return new ReactiveWebApplicationContextRunner().withConfiguration(
			AutoConfigurations.of(ApiVersionWebFluxAutoConfiguration.class,
					ApiVersionWebMvcAutoConfiguration.class));
}
 
Example #10
Source File: ServiceBrokerWebFluxAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 4 votes vote down vote up
private ReactiveWebApplicationContextRunner webApplicationContextRunner() {
	return new ReactiveWebApplicationContextRunner().withConfiguration(autoConfigurations());
}