-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/com/learnwebservices/services/hello/HelloWebClientIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.learnwebservices.services.hello; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
class HelloWebClientIT { | ||
|
||
@Autowired | ||
WebTestClient webClient; | ||
|
||
@Test | ||
void testHello() { | ||
String request = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:hel=\"http://learnwebservices.com/services/hello\">\n" + | ||
" <soapenv:Header/>\n" + | ||
" <soapenv:Body>\n" + | ||
" <hel:HelloRequest>\n" + | ||
" <hel:Name>John Doe</hel:Name>\n" + | ||
" </hel:HelloRequest>\n" + | ||
" </soapenv:Body>\n" + | ||
"</soapenv:Envelope>"; | ||
|
||
String response = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" + | ||
" <soap:Body>\n" + | ||
" <HelloResponse xmlns=\"http://learnwebservices.com/services/hello\">\n" + | ||
" <Message>Hello John Doe!</Message>\n" + | ||
" </HelloResponse>\n" + | ||
" </soap:Body>\n" + | ||
"</soap:Envelope>"; | ||
|
||
webClient | ||
.post() | ||
.uri("/services/hello") | ||
.contentType(MediaType.APPLICATION_XML) | ||
.header("SOAPAction", "") | ||
.bodyValue(request) | ||
.exchange() | ||
.expectStatus().isOk() | ||
.expectBody().xml(response); | ||
} | ||
} |