org.springframework.boot.test.context.runner.WebApplicationContextRunner Java Examples
The following examples show how to use
org.springframework.boot.test.context.runner.WebApplicationContextRunner.
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: ConsulServiceRegistryDisabledTests.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
private void testAutoRegistrationDisabled(String testName, String disableProperty) { new WebApplicationContextRunner().withUserConfiguration(TestConfig.class) .withPropertyValues("spring.application.name=" + testName, disableProperty + "=false", "server.port=0") .run(context -> { assertThat(context).doesNotHaveBean(ConsulServiceRegistry.class); assertThat(context).doesNotHaveBean(HeartbeatProperties.class); ConsulClient consul = context.getBean(ConsulClient.class); Response<Map<String, Service>> response = consul.getAgentServices(); Map<String, Service> services = response.getValue(); Service service = services.get(testName); assertThat(service).as("service was registered").isNull(); }); }
Example #2
Source File: ConsulAutoServiceRegistrationDisabledTests.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
private void testAutoRegistrationDisabled(String testName, String disableProperty) { new WebApplicationContextRunner().withUserConfiguration(TestConfig.class) .withPropertyValues("spring.application.name=" + testName, disableProperty + "=false", "server.port=0") .run(context -> { assertThat(context) .doesNotHaveBean(ConsulAutoServiceRegistration.class); assertThat(context) .doesNotHaveBean(ConsulAutoServiceRegistrationListener.class); assertThat(context).doesNotHaveBean(ConsulAutoRegistration.class); assertThat(context) .doesNotHaveBean(ConsulRegistrationCustomizer.class); ConsulClient consul = context.getBean(ConsulClient.class); Response<Map<String, Service>> response = consul.getAgentServices(); Map<String, Service> services = response.getValue(); Service service = services.get(testName); assertThat(service).as("service was registered").isNull(); }); }
Example #3
Source File: CompositUtilsTests.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void getCompositeTypeListFails() { this.thrown.expect(IllegalStateException.class); new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.config.name:compositeconfigserver", "spring.jmx.enabled=false", "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[0].type:git", "spring.cloud.config.server.composite[2].uri:file:///./target/repos/svn-config-repo", "spring.cloud.config.server.composite[2].type:svn") .run(context -> { CompositeUtils.getCompositeTypeList(context.getEnvironment()); }); }
Example #4
Source File: CompositUtilsTests.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void getCompositeTypeListWorks() { new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.config.name:compositeconfigserver", "spring.jmx.enabled=false", "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[0].type:git", "spring.cloud.config.server.composite[1].uri:file:///./target/repos/svn-config-repo", "spring.cloud.config.server.composite[1].type:svn") .run(context -> { List<String> types = CompositeUtils .getCompositeTypeList(context.getEnvironment()); assertThat(types).containsExactly("git", "svn"); }); }
Example #5
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 #6
Source File: XsuaaResourceServerJwkAutoConfigurationTest.java From cloud-security-xsuaa-integration with Apache License 2.0 | 5 votes |
@Before public void setup() { contextRunner = new WebApplicationContextRunner() .withConfiguration( AutoConfigurations.of(XsuaaResourceServerJwkAutoConfiguration.class, XsuaaAutoConfiguration.class)); }
Example #7
Source File: InitializrAutoConfigurationTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void autoConfigWithCustomProjectGenerationController() { new WebApplicationContextRunner().withConfiguration(BASIC_AUTO_CONFIGURATIONS) .withUserConfiguration(CustomProjectGenerationController.class).run((context) -> { assertThat(context).hasSingleBean(ProjectGenerationController.class); assertThat(context.getBean(ProjectGenerationController.class)) .isSameAs(context.getBean("testProjectGenerationController")); }); }
Example #8
Source File: InitializrAutoConfigurationTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void webConfiguration() { WebApplicationContextRunner webContextRunner = new WebApplicationContextRunner() .withConfiguration(BASIC_AUTO_CONFIGURATIONS); webContextRunner.run((context) -> { assertThat(context).hasSingleBean(InitializrWebConfig.class); assertThat(context).hasSingleBean(ProjectGenerationController.class); assertThat(context).hasSingleBean(ProjectMetadataController.class); assertThat(context).hasSingleBean(CommandLineMetadataController.class); assertThat(context).hasSingleBean(SpringCliDistributionController.class); }); }
Example #9
Source File: CompositeClasspathTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void contextLoads() { new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false", "spring.config.name:configserver", "spring.cloud.config.server.composite[0].uri:https://source.developers.google.com", "spring.cloud.config.server.composite[0].type:git") .run(context -> { CompositeUtils.getCompositeTypeList(context.getEnvironment()); }); }
Example #10
Source File: CompositeClasspathTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void contextLoads() { new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false", "spring.config.name:compositeconfigserver", "spring.cloud.config.server.composite[0].uri:file:///./target/repos/svn-config-repo", "spring.cloud.config.server.composite[0].type:svn", "spring.cloud.config.server.composite[1].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[1].type:native") .run(context -> { CompositeUtils.getCompositeTypeList(context.getEnvironment()); }); }
Example #11
Source File: CompositeClasspathTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void contextLoads() { new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false", "spring.config.name:compositeconfigserver", "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[0].type:git", "spring.cloud.config.server.composite[1].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[1].type:native") .run(context -> { CompositeUtils.getCompositeTypeList(context.getEnvironment()); }); }
Example #12
Source File: CompositeClasspathTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void contextLoads() { new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false", "spring.config.name:compositeconfigserver", "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[0].type:git", "spring.cloud.config.server.composite[1].uri:file:///./target/repos/svn-config-repo", "spring.cloud.config.server.composite[1].type:svn") .run(context -> { CompositeUtils.getCompositeTypeList(context.getEnvironment()); }); }
Example #13
Source File: CompositeClasspathTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void contextLoads() { new WebApplicationContextRunner() .withUserConfiguration(ConfigServerApplication.class) .withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false", "spring.config.name:compositeconfigserver", "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[0].type:git", "spring.cloud.config.server.composite[1].uri:file:///./target/repos/svn-config-repo", "spring.cloud.config.server.composite[1].type:svn") .run(context -> { CompositeUtils.getCompositeTypeList(context.getEnvironment()); }); }
Example #14
Source File: EurekaHttpClientsOptionalArgsConfigurationTest.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void contextLoadsWithRestTemplateAsDefault() { new WebApplicationContextRunner() .withUserConfiguration(EurekaSampleApplication.class).run(context -> { assertThat(context) .hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class); assertThat(context) .doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class); }); }
Example #15
Source File: EurekaHttpClientsOptionalArgsConfigurationTest.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void contextLoadsWithWebClient() { new WebApplicationContextRunner() .withUserConfiguration(EurekaSampleApplication.class) .withPropertyValues("eureka.client.webclient.enabled=true") .run(context -> { assertThat(context).doesNotHaveBean( RestTemplateDiscoveryClientOptionalArgs.class); assertThat(context) .hasSingleBean(WebClientDiscoveryClientOptionalArgs.class); }); }
Example #16
Source File: EurekaHttpClientsOptionalArgsConfigurationTest.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void contextLoadsWithRestTemplate() { new WebApplicationContextRunner() .withUserConfiguration(EurekaSampleApplication.class) .withPropertyValues("eureka.client.webclient.enabled=false") .run(context -> { assertThat(context) .hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class); assertThat(context) .doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class); }); }
Example #17
Source File: FeignHalAutoConfigurationContextTests.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Before public void setUp() { contextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, HypermediaAutoConfiguration.class, RepositoryRestMvcAutoConfiguration.class, FeignHalAutoConfiguration.class)) .withPropertyValues("debug=true"); }
Example #18
Source File: CredHubOAuth2AutoConfigurationTests.java From spring-credhub with Apache License 2.0 | 5 votes |
@Test public void oauth2ContextConfiguredWithWebApp() { new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(this.configurations)) .withPropertyValues(this.oAuth2ClientProperties).run((context) -> { assertServletOAuth2ContextConfigured(context); assertReactiveOAuth2ContextConfigured(context); }); }
Example #19
Source File: EurekaInstanceAutoConfigurationTest.java From spring-cloud-services-starters with Apache License 2.0 | 5 votes |
@Before public void setUp() { contextRunner = new WebApplicationContextRunner() .withPropertyValues("eureka.client.serviceUrl.defaultZone=" + ZONE_URI, "vcap.application.uris[0]=" + HOSTNAME, "vcap.application.instance_id=" + INSTANCE_ID, "vcap.application.application_id=" + INSTANCE_GUID, "cf.instance.index=" + INSTANCE_INDEX, "cf.instance.internal.ip=" + IP, "port=" + PORT) .withConfiguration(AutoConfigurations.of(EurekaInstanceAutoConfiguration.class)); }
Example #20
Source File: SpringSessionFixAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach void setUp() { this.contextRunner = new WebApplicationContextRunner(); }
Example #21
Source File: CamundaBpmWebappAutoConfigurationIntegrationTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Before public void setUp() { AutoConfigurations autoConfigurationsUnderTest = AutoConfigurations.of(CamundaBpmAutoConfiguration.class, CamundaBpmWebappAutoConfiguration.class); AutoConfigurations additionalAutoConfigurations = AutoConfigurations.of(DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class); contextRunner = new WebApplicationContextRunner().withConfiguration(autoConfigurationsUnderTest).withConfiguration(additionalAutoConfigurations); }
Example #22
Source File: AngularfacesAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(AngularfacesAutoConfiguration.class, JavaxFacesAutoConfiguration.class)); }
Example #23
Source File: RewriteAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(RewriteAutoConfiguration.class, FooConfiguration.class)); }
Example #24
Source File: SpringBootAnnotationConfigProviderTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach void setup() { this.webApplicationContextRunner = new WebApplicationContextRunner().withConfiguration( AutoConfigurations.of(RewriteAutoConfiguration.class, FooConfiguration.class)); }
Example #25
Source File: FacesServletAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(FacesServletAutoConfiguration.class, JavaxFacesAutoConfiguration.class)); }
Example #26
Source File: ProjectStageAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(JavaxFacesAutoConfiguration.class, ProjectStageAutoConfiguration.class)); }
Example #27
Source File: JpaWebAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(JpaWebAutoConfiguration.class, HibernateJpaAutoConfiguration.class)); }
Example #28
Source File: AdminfacesAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(AdminfacesAutoConfiguration.class, PrimefacesAutoConfiguration.class)); }
Example #29
Source File: JoinfacesAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(JoinfacesAutoConfiguration.class)); }
Example #30
Source File: FileUploadFilterTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(PrimefacesFileUploadServletContextAutoConfiguration.class, MultipartAutoConfiguration.class)); }