Uploaded by Usha Shankar

WebService Testing Using Apache Cleint

advertisement
Web Service testing using Apache Client
Content of the Course
•
•
•
•
•
•
•
Basic of Web Service i.e. what is REST and its advantages etc.
How to test the web service using client such as POSTMAN.
Deep dive in the coding.
Validation of Web service using Junit assert.
Web Service with authentication.
Parallely developing the framework using Maven.
Code optimization
Prerequisite
•
•
•
•
You should have basic under standing of Oops concept.
Basic knowledge of tomcat server
Basic understanding of eclipse.
Basic knowledge of programming language Java
Tools Required
•
•
•
•
Java Development Kit (jdk 1.8)
Apache Tomcat (version 8.0)
Eclipse Luna.
Postman Client
Environment Setup
•
•
•
•
Java Development Kit (jdk 1.8)
Apache Tomcat (version 8.0)
Eclipse Luna.
Postman Client
What is a web service?
• A web service is a function that can be accessed by the other
programme over the web.
Client
System 1
Access the resources
Server
System 2
Request / Response
Client
Server
Request
System 2
System 1
Response
• Simple Object Access Protocol aka SOAP
• REpresentational State Transfer aka REST
What is REST?
• REpresentational State Transfer and its an architecture
• REST Uses HTTP protocol for the communication
• It was developed to overcome the limitation SOAP. And to make the
web services light weight
• In REST “REpresentational” means, resource can be represent in
different format such as text, JSON and XML
• Web Service developed using REST architecture aka RESTful Apis
HTTP Methods
• For any application “CRUD” operations are common.
• Create HTTP POST Method
• Read HTTP GET Method
• Update HTTP PUT Method
• Delete HTTP DELETE Method
Request / Response
• Request Format
• Headers - Optional
• Body - Optional
• Method – Not Optional
• Response Format
• Headers - Optional
• Body - Optional
• Status Code – Not Optional
Level of Validation
• Level – 1 , check for response body is empty or not
• Level – 2, check for response body is empty or not along with status
code
• Level – 3, check the response body content along with status code
What is JSON
• Its stands for JavaScript Object Notation
• It is used to transfer the data between a server and a web application.
{
"BrandName": "Dell",
"Features": {
"Feature": ["8GB RAM",
"1TB Hard Drive"]
},
"Id": 126,
"LaptopName": "Latitude"
}
Maven Project
• Maven will take care of dependency management.
• Maven will take care of packaging.
Project Dependency
• Junit , a unit testing framework.
• Apache HttpClient Api, for working with Http Protocol. Also interacting
with web services
Serialization/Deserialization
• Serialization, it’s a process of converting the state of object byte stream.
• Deserialization, it’s a process of retrieving the object from the byte
stream.
Authentication
Client
Server
Request with username &
password (encrypted)
System 2
System 1
Response
Authorize / Unauthorized
Secure Socket Layer (SSL)
Client request server to identify itself
The server sends the browser a copy of its SSL
Certificate
Client
The browser checks whether it trusts the SSL
certificate. If so, it sends a message to the server
The server sends back a digitally signed
acknowledgement to start an SSL encrypted session
Server
Maven a build tool
•
•
•
•
Maven Clean :- Clean the working directory
Maven Compile :- Compile the project
Maven Build :- Build the project
Maven Install :- Clean , Compile , Build, Test and put the package jar in
local maven repository
• Maven Package :- Package the project in the jar or war file
Download