Java Code Examples for org.springframework.test.web.reactive.server.EntityExchangeResult#getResponseBody()
The following examples show how to use
org.springframework.test.web.reactive.server.EntityExchangeResult#getResponseBody() .
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: AbstractSpringDocTest.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@Test public void testApp() throws Exception { String result = null; try { EntityExchangeResult<byte[]> getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() .expectStatus().isOk().expectBody().returnResult(); result = new String(getResult.getResponseBody()); String className = getClass().getSimpleName(); String testNumber = className.replaceAll("[^0-9]", ""); String expected = getContent("results/app" + testNumber + ".json"); assertEquals(expected, result, true); } catch (java.lang.AssertionError e) { LOGGER.error(result); throw e; } }
Example 2
Source File: AbstractSpringDocTest.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Test public void testApp() throws Exception { EntityExchangeResult<byte[]> getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() .expectStatus().isOk().expectBody().returnResult(); String result = new String(getResult.getResponseBody()); String className = getClass().getSimpleName(); String testNumber = className.replaceAll("[^0-9]", ""); String expected = getContent("results/app" + testNumber + ".json"); JSONAssert.assertEquals(expected, result, true); }
Example 3
Source File: SpringDocApp5Test.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Test public void transformed_index_with_oauth() throws Exception { EntityExchangeResult<byte[]> getResult = webTestClient.get().uri("/webjars/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); String result = new String(getResult.getResponseBody()); assertTrue(result.contains("Swagger UI")); String expected = getContent("results/index5"); assertEquals(expected, result); }
Example 4
Source File: SpringDocApp7Test.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Test public void transformed_index_with_oauth() throws Exception { EntityExchangeResult<byte[]> getResult = webTestClient.get().uri("/webjars/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); String result = new String(getResult.getResponseBody()); assertTrue(result.contains("Swagger UI")); String expected = getContent("results/index7"); assertEquals(expected, result); }
Example 5
Source File: SpringDocApp6Test.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Test public void transformed_index_with_oauth() throws Exception { EntityExchangeResult<byte[]> getResult = webTestClient.get().uri("/webjars/swagger-ui/index.html") .exchange() .expectStatus().isOk() .expectBody().returnResult(); String result = new String(getResult.getResponseBody()); assertTrue(result.contains("Swagger UI")); String expected = getContent("results/index6"); assertEquals(expected, result); }
Example 6
Source File: DemoApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Test public void postCrudOperations() { int randomInt = new Random().nextInt(); String title = "Post test " + randomInt; FluxExchangeResult<Void> postResult = client .mutate().filter(basicAuthentication("user", "password")).build() .post() .uri("/posts") .body(BodyInserters.fromObject(Post.builder().title(title).content("content of " + title).build())) .exchange() .expectStatus().isEqualTo(HttpStatus.CREATED) .returnResult(Void.class); URI location = postResult.getResponseHeaders().getLocation(); assertNotNull(location); EntityExchangeResult<byte[]> getResult = client .get() .uri(location) .exchange() .expectStatus().isOk() .expectBody().jsonPath("$.title").isEqualTo(title) .returnResult(); String getPost = new String(getResult.getResponseBody()); assertTrue(getPost.contains(title)); }
Example 7
Source File: DemoApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Test public void postCrudOperations() { int randomInt = new Random().nextInt(); String title = "Post test " + randomInt; FluxExchangeResult<Void> postResult = client .mutate().filter(basicAuthentication("user", "password")).build() .post() .uri("/posts") .body(BodyInserters.fromObject(Post.builder().title(title).content("content of " + title).build())) .exchange() .expectStatus().isEqualTo(HttpStatus.CREATED) .returnResult(Void.class); URI location = postResult.getResponseHeaders().getLocation(); assertNotNull(location); EntityExchangeResult<byte[]> getResult = client .get() .uri(location) .exchange() .expectStatus().isOk() .expectBody().jsonPath("$.title").isEqualTo(title) .returnResult(); String getPost = new String(getResult.getResponseBody()); assertTrue(getPost.contains(title)); }
Example 8
Source File: DemoApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Test public void postCrudOperations() { int randomInt = new Random().nextInt(); String title = "Post test " + randomInt; FluxExchangeResult<Void> postResult = client .mutate().filter(basicAuthentication("user", "password")).build() .post() .uri("/posts") .body(BodyInserters.fromObject(Post.builder().title(title).content("content of " + title).build())) .exchange() .expectStatus().isEqualTo(HttpStatus.CREATED) .returnResult(Void.class); URI location = postResult.getResponseHeaders().getLocation(); assertNotNull(location); EntityExchangeResult<byte[]> getResult = client .get() .uri(location) .exchange() .expectStatus().isOk() .expectBody().jsonPath("$.title").isEqualTo(title) .returnResult(); String getPost = new String(getResult.getResponseBody()); assertTrue(getPost.contains(title)); }
Example 9
Source File: DemoApplicationTests.java From spring-reactive-sample with GNU General Public License v3.0 | 5 votes |
@Test public void postCrudOperations() { int randomInt = new Random().nextInt(); String title = "Post test " + randomInt; FluxExchangeResult<Void> postResult = client .mutate().filter(basicAuthentication("user", "password")).build() .post() .uri("/posts") .body(BodyInserters.fromObject(Post.builder().title(title).content("content of " + title).build())) .exchange() .expectStatus().isEqualTo(HttpStatus.CREATED) .returnResult(Void.class); URI location = postResult.getResponseHeaders().getLocation(); assertNotNull(location); EntityExchangeResult<byte[]> getResult = client .get() .uri(location) .exchange() .expectStatus().isOk() .expectBody().jsonPath("$.title").isEqualTo(title) .returnResult(); String getPost = new String(getResult.getResponseBody()); assertTrue(getPost.contains(title)); }