org.springframework.test.web.reactive.server.WebTestClient Java Examples
The following examples show how to use
org.springframework.test.web.reactive.server.WebTestClient.
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: BookStoreIntegrationTests.java From bookstore-service-broker with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() { this.service = new BookStoreService(repository); BookStoreController bookStoreController = new BookStoreController(service); BookController bookController = new BookController(service); this.client = WebTestClient.bindToController(bookStoreController, bookController) .build(); this.bookStoreId = service.createBookStore() .flatMap(bookStore -> service.putBookInStore(bookStore.getId(), new Book(BOOK1_ISBN, BOOK1_TITLE, BOOK1_AUTHOR)) .then(service.putBookInStore(bookStore.getId(), new Book(BOOK2_ISBN, BOOK2_TITLE, BOOK2_AUTHOR))) .thenReturn(bookStore.getId())) .block(); }
Example #2
Source File: RecommendationServiceApplicationTests.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
private WebTestClient.BodyContentSpec getAndVerifyRecommendationsByProductId(String productIdQuery, HttpStatus expectedStatus) { return client.get() .uri("/recommendation" + productIdQuery) .accept(APPLICATION_JSON_UTF8) .exchange() .expectStatus().isEqualTo(expectedStatus) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(); }
Example #3
Source File: ApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Before public void setup() { this.rest = WebTestClient .bindToApplicationContext(this.context) .configureClient() .build(); }
Example #4
Source File: ApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeAll public void setup() { this.client = WebTestClient .bindToApplicationContext(this.context) .configureClient() .build(); }
Example #5
Source File: NettyRoutingFilterTests.java From spring-cloud-gateway with Apache License 2.0 | 5 votes |
@Test @Ignore public void mockServerWorks() { WebTestClient client = WebTestClient.bindToApplicationContext(this.context) .build(); client.get().uri("/mockexample").exchange().expectStatus() .value(Matchers.lessThan(500)); }
Example #6
Source File: WebTestClientIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void testWebTestClientWithServerURL() { WebTestClient.bindToServer() .baseUrl("http://localhost:" + port) .build() .get() .uri("/resource") .exchange() .expectStatus() .isOk() .expectBody(); }
Example #7
Source File: IntegrationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeEach public void setup() { this.rest = WebTestClient .bindToServer() .responseTimeout(Duration.ofDays(1)) .baseUrl("http://localhost:8080") .build(); }
Example #8
Source File: FunctionalWebApplicationIntegrationTest.java From tutorials with MIT License | 5 votes |
@BeforeClass public static void setup() throws Exception { server = new FunctionalWebApplication().start(); client = WebTestClient.bindToServer() .baseUrl("http://localhost:" + server.getPort()) .build(); }
Example #9
Source File: ApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Before public void setup() { this.rest = WebTestClient .bindToApplicationContext(this.context) .apply(springSecurity()) .configureClient() .filter(basicAuthentication()) .build(); }
Example #10
Source File: PostControllerTest.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeAll public void setup() { this.client = WebTestClient .bindToController(this.ctrl) .configureClient() .build(); }
Example #11
Source File: ApplicationContextTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setUp() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(WebConfig.class); context.refresh(); this.client = WebTestClient.bindToApplicationContext(context).build(); }
Example #12
Source File: HttpServerTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void start() throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler( route(GET("/test"), request -> ServerResponse.ok().syncBody("It works!"))); this.server = new ReactorHttpServer(); this.server.setHandler(httpHandler); this.server.afterPropertiesSet(); this.server.start(); this.client = WebTestClient.bindToServer() .baseUrl("http://localhost:" + this.server.getPort()) .build(); }
Example #13
Source File: ReviewServiceApplicationTests.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
private WebTestClient.BodyContentSpec getAndVerifyReviewsByProductId(String productIdQuery, HttpStatus expectedStatus) { return client.get() .uri("/review" + productIdQuery) .accept(APPLICATION_JSON_UTF8) .exchange() .expectStatus().isEqualTo(expectedStatus) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(); }
Example #14
Source File: ApplicationSlaManagementResourceTest.java From titus-control-plane with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpClass() { when(jobOperations.getJobsAndTasks()).thenReturn(Collections.emptyList()); baseURI = jaxRsServer.getBaseURI() + ApplicationSlaManagementEndpoint.PATH_API_V2_MANAGEMENT_APPLICATIONS + '/'; testClient = WebTestClient.bindToServer() .baseUrl(baseURI) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .build(); }
Example #15
Source File: ProductServiceApplicationTests.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
private WebTestClient.BodyContentSpec getAndVerifyProduct(String productIdPath, HttpStatus expectedStatus) { return client.get() .uri("/product" + productIdPath) .accept(APPLICATION_JSON_UTF8) .exchange() .expectStatus().isEqualTo(expectedStatus) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(); }
Example #16
Source File: VertxWebTestClientRegistrarTest.java From vertx-spring-boot with Apache License 2.0 | 5 votes |
@Test public void shouldRegisterBean() { given(mockFactory.getBeanNamesForType(WebTestClient.class, false, false)) .willReturn(new String[]{}); registrar.postProcessBeanDefinitionRegistry(mockRegistry); ArgumentCaptor<RootBeanDefinition> definitionCaptor = ArgumentCaptor.forClass(RootBeanDefinition.class); verify(mockRegistry).registerBeanDefinition(eq(WebTestClient.class.getName()), definitionCaptor.capture()); RootBeanDefinition definition = definitionCaptor.getValue(); assertThat(definition.getBeanClass()).isEqualTo(WebTestClient.class); assertThat(definition.getInstanceSupplier()).isInstanceOf(VertxWebTestClientSupplier.class); assertThat(definition.isLazyInit()).isTrue(); }
Example #17
Source File: RouterFunctionTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setUp() throws Exception { RouterFunction<?> route = route(GET("/test"), request -> ServerResponse.ok().syncBody("It works!")); this.testClient = WebTestClient.bindToRouterFunction(route).build(); }
Example #18
Source File: CorsOnAnnotatedElementsLiveTest.java From tutorials with MIT License | 5 votes |
@BeforeAll public static void setup() { client = WebTestClient.bindToServer() .baseUrl(BASE_URL) .defaultHeader("Origin", CORS_DEFAULT_ORIGIN) .build(); }
Example #19
Source File: IntegrationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeEach public void setup() { this.client = WebTestClient .bindToServer() .responseTimeout(Duration.ofDays(1)) .baseUrl("http://localhost:8080") .build(); }
Example #20
Source File: RecommendationServiceApplicationTests.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
private WebTestClient.BodyContentSpec getAndVerifyRecommendationsByProductId(String productIdQuery, HttpStatus expectedStatus) { return client.get() .uri("/recommendation" + productIdQuery) .accept(APPLICATION_JSON_UTF8) .exchange() .expectStatus().isEqualTo(expectedStatus) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(); }
Example #21
Source File: PostControllerTest.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeAll public void setup() { this.client = WebTestClient .bindToController(this.ctrl) .configureClient() .build(); }
Example #22
Source File: IntegrationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeEach public void setup() { this.client = WebTestClient .bindToServer() .responseTimeout(Duration.ofSeconds(300)) .baseUrl("http://localhost:8080") .build(); }
Example #23
Source File: ReviewServiceApplicationTests.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
private WebTestClient.BodyContentSpec getAndVerifyReviewsByProductId(String productIdQuery, HttpStatus expectedStatus) { return client.get() .uri("/review" + productIdQuery) .accept(APPLICATION_JSON_UTF8) .exchange() .expectStatus().isEqualTo(expectedStatus) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(); }
Example #24
Source File: InstancesControllerIntegrationTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() { instance = new SpringApplicationBuilder().sources(AdminReactiveApplicationTest.TestAdminApplication.class) .web(WebApplicationType.REACTIVE).run("--server.port=0", "--eureka.client.enabled=false"); localPort = instance.getEnvironment().getProperty("local.server.port", Integer.class, 0); this.client = WebTestClient.bindToServer().baseUrl("http://localhost:" + localPort).build(); this.register_as_test = "{ \"name\": \"test\", \"healthUrl\": \"http://localhost:" + localPort + "/application/health\" }"; this.register_as_twice = "{ \"name\": \"twice\", \"healthUrl\": \"http://localhost:" + localPort + "/application/health\" }"; }
Example #25
Source File: IntegrationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Before public void setup() { this.rest = WebTestClient .bindToServer() .responseTimeout(Duration.ofDays(1)) .baseUrl("http://localhost:" + this.port) .build(); }
Example #26
Source File: ApiControllerContractTests.java From event-store-demo with GNU General Public License v3.0 | 5 votes |
@Test public void testRenameBoard() throws Exception { WebTestClient.bindToController( this.controller ) .build() .patch() .uri( "/boards/{boardUuid}?name={name}", boardUuid, "New Name" ) .exchange() .expectStatus().isAccepted(); }
Example #27
Source File: IntegrationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@BeforeAll public void setup() { this.disposableServer = this.httpServer.bindNow(); this.client = WebTestClient .bindToServer() .responseTimeout(Duration.ofDays(1)) .baseUrl("http://localhost:" + this.port) .build(); }
Example #28
Source File: BaseWebClientTests.java From spring-cloud-gateway with Apache License 2.0 | 5 votes |
protected void setup(ClientHttpConnector httpConnector, String baseUri) { this.baseUri = baseUri; this.webClient = WebClient.builder().clientConnector(httpConnector) .baseUrl(this.baseUri).build(); this.testClient = WebTestClient.bindToServer(httpConnector).baseUrl(this.baseUri) .build(); }
Example #29
Source File: AbstractInstancesProxyControllerIntegrationTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
protected void setUpClient(ConfigurableApplicationContext context) { int localPort = context.getEnvironment().getProperty("local.server.port", Integer.class, 0); this.client = WebTestClient.bindToServer().baseUrl("http://localhost:" + localPort) .responseTimeout(Duration.ofSeconds(10)).build(); this.instanceId = registerInstance("/instance1"); }
Example #30
Source File: RecommendationServiceApplicationTests.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
private WebTestClient.BodyContentSpec getAndVerifyRecommendationsByProductId(String productIdQuery, HttpStatus expectedStatus) { return client.get() .uri("/recommendation" + productIdQuery) .accept(APPLICATION_JSON_UTF8) .exchange() .expectStatus().isEqualTo(expectedStatus) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(); }