org.springframework.boot.context.annotation.UserConfigurations Java Examples
The following examples show how to use
org.springframework.boot.context.annotation.UserConfigurations.
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: QueueMessageHandlerTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void receiveMessage_methodWithMessageAsParameter_parameterIsConverted() { new ApplicationContextRunner() .withConfiguration(UserConfigurations .of(QueueMessageHandlerWithJacksonMappingConfiguration.class)) .withBean(IncomingMessageHandlerWithMessageParameter.class) .run((context) -> { DummyKeyValueHolder messagePayload = new DummyKeyValueHolder("myKey", "A value"); MappingJackson2MessageConverter jsonMapper = context .getBean(MappingJackson2MessageConverter.class); Message<?> message = jsonMapper.toMessage(messagePayload, new MessageHeaders(Collections.singletonMap( QueueMessageHandler.LOGICAL_RESOURCE_ID, "testQueue"))); MessageHandler messageHandler = context.getBean(MessageHandler.class); messageHandler.handleMessage(message); IncomingMessageHandlerWithMessageParameter messageListener = context .getBean(IncomingMessageHandlerWithMessageParameter.class); assertThat(messageListener.getLastReceivedMessage()).isNotNull(); assertThat(messageListener.getLastReceivedMessage().getPayload()) .isEqualTo(messagePayload); }); }
Example #2
Source File: SpringVaultClientConfigurationTests.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("deprecation") public void springVaultClientConfigurationIsAProxy() { new WebApplicationContextRunner() .withPropertyValues("spring.profiles.active=vault") .withConfiguration(UserConfigurations.of(ConfigServerConfiguration.class)) .withConfiguration( AutoConfigurations.of(ConfigServerAutoConfiguration.class)) .run(context -> { assertThat(context).getBean(SpringVaultClientConfiguration.class) .isNotNull() .matches(svcc -> ClassUtils .isCglibProxyClassName(svcc.getClass().getName()), "is a proxy"); }); }
Example #3
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_context_path_and_base_path_set_to_root() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.endpoints.web.base-path=/", "server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "foo(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #4
Source File: QueueMessageHandlerTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void receiveMessage_methodWithCustomObjectAsParameter_parameterIsConverted() { new ApplicationContextRunner() .withConfiguration(UserConfigurations .of(QueueMessageHandlerWithJacksonMappingConfiguration.class)) .withBean(IncomingMessageHandlerWithCustomParameter.class) .run((context) -> { DummyKeyValueHolder messagePayload = new DummyKeyValueHolder("myKey", "A value"); MappingJackson2MessageConverter jsonMapper = context .getBean(MappingJackson2MessageConverter.class); Message<?> message = jsonMapper.toMessage(messagePayload, new MessageHeaders(Collections.singletonMap( QueueMessageHandler.LOGICAL_RESOURCE_ID, "testQueue"))); MessageHandler messageHandler = context.getBean(MessageHandler.class); messageHandler.handleMessage(message); IncomingMessageHandlerWithCustomParameter messageListener = context .getBean(IncomingMessageHandlerWithCustomParameter.class); assertThat(messageListener.getLastReceivedMessage()).isNotNull(); assertThat(messageListener.getLastReceivedMessage().getKey()) .isEqualTo("myKey"); assertThat(messageListener.getLastReceivedMessage().getValue()) .isEqualTo("A value"); }); }
Example #5
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_context_path_different_port() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.server.port=0", "server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/actuator(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #6
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_actuator_context_path_only_different_port() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.endpoints.web.base-path=/mgt", "management.server.port=0", "server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/mgt(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #7
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_actuator_default_context_path_different_port() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.server.port=0", "server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/actuator(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #8
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_actuator_context_path_only() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.endpoints.web.base-path=/mgt", "server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "foo/mgt(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #9
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_context_path_and_base_path_set_to_root_different_port() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.endpoints.web.base-path=/", "management.server.port=0", "server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/(health|health/.*|info|info/.*)", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #10
Source File: MongoTracingAutoConfigurationTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Test public void createsTracingPostProcessor() { final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withPropertyValues("spring.data.mongodb.port=27017") // Otherwise a random embedded mongo port is used .withConfiguration(UserConfigurations.of(TracerConfig.class, MongoConfig.class)) .withConfiguration(AutoConfigurations.of( MongoTracingAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class )); contextRunner.run(context -> Assertions.assertThat(context).hasSingleBean(TracingMongoClientPostProcessor.class)); }
Example #11
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_without_context_path_and_base_path_set_to_root() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("management.endpoints.web.base-path=/") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/(health|health/.*|info|info/.*)", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #12
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_with_context_path() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .withPropertyValues("server.servlet.context-path=foo").run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "foo/actuator(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #13
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_endpoints_without_context_path() { contextRunner .withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class)) .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/actuator(/|/(health|health/.*|info|info/.*))?", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #14
Source File: SkipPatternProviderConfigTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_return_management_context_with_context_path() throws Exception { contextRunner .withConfiguration( UserConfigurations.of(ManagementContextAutoConfiguration.class, ServerPropertiesConfig.class)) .withPropertyValues("management.server.servlet.context-path=foo") .run(context -> { then(extractAllPatterns(context)).containsExactlyInAnyOrder( "/actuator(/|/(health|health/.*|info|info/.*))?", "foo.*", SleuthWebProperties.DEFAULT_SKIP_PATTERN); }); }
Example #15
Source File: MongoTracingAutoConfigurationTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Test public void doesNotCreateTracingPostProcessorWhenDisabled() { final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withPropertyValues("opentracing.spring.cloud.mongo.enabled=false") .withConfiguration(UserConfigurations.of(TracerConfig.class, MongoConfig.class)) .withConfiguration(AutoConfigurations.of(MongoTracingAutoConfiguration.class)); contextRunner.run(context -> Assertions.assertThat(context).doesNotHaveBean(TracingMongoClientPostProcessor.class)); }
Example #16
Source File: MongoTracingAutoConfigurationTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Test public void doesNotCreateTracingPostProcessorWhenNoMongoClient() { final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(UserConfigurations.of(TracerConfig.class)) .withConfiguration(AutoConfigurations.of(MongoTracingAutoConfiguration.class)); contextRunner.run(context -> Assertions.assertThat(context).doesNotHaveBean(TracingMongoClientPostProcessor.class)); }
Example #17
Source File: MongoTracingAutoConfigurationTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Test public void doesNotCreateTracingPostProcessorWhenNoTracer() { final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(UserConfigurations.of(MongoConfig.class)) .withConfiguration(AutoConfigurations.of(MongoTracingAutoConfiguration.class)); contextRunner.run(context -> Assertions.assertThat(context).doesNotHaveBean(TracingMongoClientPostProcessor.class)); }