@@ -7,6 +7,7 @@ import wslite.rest.RESTClientException
7
7
import wslite.soap.SOAPClient
8
8
import wslite.soap.SOAPMessageBuilder
9
9
import wslite.http.auth.HTTPBasicAuthorization
10
+ import org.junit.Test
10
11
11
12
class WebserviceUnitTest extends GroovyTestCase {
12
13
@@ -19,7 +20,7 @@ class WebserviceUnitTest extends GroovyTestCase {
19
20
client. httpClient. sslTrustAllCerts = true
20
21
}
21
22
22
- void testHttpGetRequest () {
23
+ void test_whenSendingGet_thenRespose200 () {
23
24
def postmanGet = new URL (' https://postman-echo.com/get' )
24
25
def getConnection = postmanGet. openConnection()
25
26
getConnection. requestMethod = ' GET'
@@ -29,15 +30,15 @@ class WebserviceUnitTest extends GroovyTestCase {
29
30
}
30
31
}
31
32
32
- void testHttpPostRequest () {
33
+ void test_whenSendingPost_thenRespose200 () {
33
34
def postmanPost = new URL (' https://postman-echo.com/post' )
34
35
def query = " q=This is post request form parameter."
35
36
def postConnection = postmanPost. openConnection()
36
37
postConnection. requestMethod = ' POST'
37
38
assert postConnection. responseCode == 200
38
39
}
39
40
40
- void testHttpPostRequestWithParams () {
41
+ void test_whenSendingPostWithParams_thenRespose200 () {
41
42
def postmanPost = new URL (' https://postman-echo.com/post' )
42
43
def form = " param1=This is request parameter."
43
44
def postConnection = postmanPost. openConnection()
@@ -54,7 +55,7 @@ class WebserviceUnitTest extends GroovyTestCase {
54
55
assert jsonSlurper. parseText(text)?. json. param1 == " This is request parameter."
55
56
}
56
57
57
- void testRssFeed () {
58
+ void test_whenReadingRSS_thenReceiveFeed () {
58
59
def rssFeed = new XmlParser (). parse(" https://news.google.com/rss?hl=en-US&gl=US&ceid=US:en" )
59
60
def stories = []
60
61
(0 .. 4 ). each {
@@ -64,7 +65,7 @@ class WebserviceUnitTest extends GroovyTestCase {
64
65
assert stories. size() == 5
65
66
}
66
67
67
- void testAtomFeed () {
68
+ void test_whenReadingAtom_thenReceiveFeed () {
68
69
def atomFeed = new XmlParser (). parse(" https://news.google.com/atom?hl=en-US&gl=US&ceid=US:en" )
69
70
def stories = []
70
71
(0 .. 4 ). each {
@@ -74,7 +75,7 @@ class WebserviceUnitTest extends GroovyTestCase {
74
75
assert stories. size() == 5
75
76
}
76
77
77
- void testSoapClient () {
78
+ void test_whenConsumingSoap_thenReceiveResponse () {
78
79
def url = " http://www.dataaccess.com/webservicesserver/numberconversion.wso"
79
80
def soapClient = new SOAPClient (url)
80
81
def message = new SOAPMessageBuilder (). build({
@@ -89,7 +90,7 @@ class WebserviceUnitTest extends GroovyTestCase {
89
90
assert words == " one thousand two hundred and thirty four "
90
91
}
91
92
92
- void testRestClientGet () {
93
+ void test_whenConsumingRestGet_thenReceiveResponse () {
93
94
def path = " /get"
94
95
def response
95
96
try {
@@ -101,7 +102,7 @@ class WebserviceUnitTest extends GroovyTestCase {
101
102
}
102
103
}
103
104
104
- void testRestClientPost () {
105
+ void test_whenConsumingRestPost_thenReceiveResponse () {
105
106
def path = " /post"
106
107
def params = [" foo" :1 ," bar" :2 ]
107
108
def response
@@ -117,7 +118,7 @@ class WebserviceUnitTest extends GroovyTestCase {
117
118
}
118
119
}
119
120
120
- void testBasicAuthentication () {
121
+ void test_whenBasicAuthentication_thenReceive200 () {
121
122
def path = " /basic-auth"
122
123
def response
123
124
try {
@@ -131,7 +132,7 @@ class WebserviceUnitTest extends GroovyTestCase {
131
132
}
132
133
}
133
134
134
- void testOAuth () {
135
+ void test_whenOAuth_thenReceive200 () {
135
136
RESTClient oAuthClient = new RESTClient (" https://postman-echo.com" )
136
137
oAuthClient. defaultAcceptHeader = ContentType . JSON
137
138
oAuthClient. httpClient. sslTrustAllCerts = true
0 commit comments