Skip to content

Commit cb1de34

Browse files
committed
BAEL-3190 - working with webservices in groovy - followed test names convention
1 parent 5b2dec5 commit cb1de34

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import wslite.rest.RESTClientException
77
import wslite.soap.SOAPClient
88
import wslite.soap.SOAPMessageBuilder
99
import wslite.http.auth.HTTPBasicAuthorization
10+
import org.junit.Test
1011

1112
class WebserviceUnitTest extends GroovyTestCase {
1213

@@ -19,7 +20,7 @@ class WebserviceUnitTest extends GroovyTestCase {
1920
client.httpClient.sslTrustAllCerts = true
2021
}
2122

22-
void testHttpGetRequest() {
23+
void test_whenSendingGet_thenRespose200() {
2324
def postmanGet = new URL('https://postman-echo.com/get')
2425
def getConnection = postmanGet.openConnection()
2526
getConnection.requestMethod = 'GET'
@@ -29,15 +30,15 @@ class WebserviceUnitTest extends GroovyTestCase {
2930
}
3031
}
3132

32-
void testHttpPostRequest() {
33+
void test_whenSendingPost_thenRespose200() {
3334
def postmanPost = new URL('https://postman-echo.com/post')
3435
def query = "q=This is post request form parameter."
3536
def postConnection = postmanPost.openConnection()
3637
postConnection.requestMethod = 'POST'
3738
assert postConnection.responseCode == 200
3839
}
3940

40-
void testHttpPostRequestWithParams() {
41+
void test_whenSendingPostWithParams_thenRespose200() {
4142
def postmanPost = new URL('https://postman-echo.com/post')
4243
def form = "param1=This is request parameter."
4344
def postConnection = postmanPost.openConnection()
@@ -54,7 +55,7 @@ class WebserviceUnitTest extends GroovyTestCase {
5455
assert jsonSlurper.parseText(text)?.json.param1 == "This is request parameter."
5556
}
5657

57-
void testRssFeed() {
58+
void test_whenReadingRSS_thenReceiveFeed() {
5859
def rssFeed = new XmlParser().parse("https://news.google.com/rss?hl=en-US&gl=US&ceid=US:en")
5960
def stories = []
6061
(0..4).each {
@@ -64,7 +65,7 @@ class WebserviceUnitTest extends GroovyTestCase {
6465
assert stories.size() == 5
6566
}
6667

67-
void testAtomFeed() {
68+
void test_whenReadingAtom_thenReceiveFeed() {
6869
def atomFeed = new XmlParser().parse("https://news.google.com/atom?hl=en-US&gl=US&ceid=US:en")
6970
def stories = []
7071
(0..4).each {
@@ -74,7 +75,7 @@ class WebserviceUnitTest extends GroovyTestCase {
7475
assert stories.size() == 5
7576
}
7677

77-
void testSoapClient() {
78+
void test_whenConsumingSoap_thenReceiveResponse() {
7879
def url = "http://www.dataaccess.com/webservicesserver/numberconversion.wso"
7980
def soapClient = new SOAPClient(url)
8081
def message = new SOAPMessageBuilder().build({
@@ -89,7 +90,7 @@ class WebserviceUnitTest extends GroovyTestCase {
8990
assert words == "one thousand two hundred and thirty four "
9091
}
9192

92-
void testRestClientGet() {
93+
void test_whenConsumingRestGet_thenReceiveResponse() {
9394
def path = "/get"
9495
def response
9596
try {
@@ -101,7 +102,7 @@ class WebserviceUnitTest extends GroovyTestCase {
101102
}
102103
}
103104

104-
void testRestClientPost() {
105+
void test_whenConsumingRestPost_thenReceiveResponse() {
105106
def path = "/post"
106107
def params = ["foo":1,"bar":2]
107108
def response
@@ -117,7 +118,7 @@ class WebserviceUnitTest extends GroovyTestCase {
117118
}
118119
}
119120

120-
void testBasicAuthentication() {
121+
void test_whenBasicAuthentication_thenReceive200() {
121122
def path = "/basic-auth"
122123
def response
123124
try {
@@ -131,7 +132,7 @@ class WebserviceUnitTest extends GroovyTestCase {
131132
}
132133
}
133134

134-
void testOAuth() {
135+
void test_whenOAuth_thenReceive200() {
135136
RESTClient oAuthClient = new RESTClient("https://postman-echo.com")
136137
oAuthClient.defaultAcceptHeader = ContentType.JSON
137138
oAuthClient.httpClient.sslTrustAllCerts = true

0 commit comments

Comments
 (0)