API
API means Application Programming Interface
API is also called as Web Services.
Types of applications
- Standalone application
- Client server
Standalone application
- This type of application does not require internet.
- No server required
- No browser
- Single user
- Ex: Notepad, paint, calculator, MS Office, Browser
Client server
Client server requires internet, server, and bowser to access it. Multiple users can use client server.
- Client server
- Web application
Client server
Client server like WhatsApp, Telegram app etc.
Every client has its own server.
Client server requires client software to access it.
Example:
When we sent HI from client software (like WhatsApp), this
client software will send request to software server (where source code
present) where send source will execute and sent it back request to the client
software that he can send the message.
Web application
Web application like Facebook, Gmail etc.
Web application require browser to access server.
Example
When we access a URL using browser like chrome, Firefox,
etc., this Facebook URL is used to get request from Facebook server where
Facebook server will executed login page code (.java file) and returns response
to open Facebook login page in browser.
Introduction to web application
Web application requires browser to communicate with the
server.
Server
It is a computer which will give access to communicate with
web server and app server.
Every server also have RAM, HDD, OS (ex: 256GB RAM, 1000TD
HDD, Windows 11)
It consists of two sub servers
- Web server
- App server/ Web application
Web server
Web server consists of ‘.html’ code which is used to access
the ‘.java file’ through a communicator ‘servlet’.
App server
It consists of ‘.java’ code of the application which is used
to execute the program.
Servlet
Servlet is also used for mapping between HTML and java
files..
JDBC
JDBC stands for Java Database connectivity
It is used to connect java object with the database
Layers of Web server
- Presentation Layer
- Business Layer
- Database Layer
Presentation layer consists of Web Server i.e. ‘.html’ code.
Business layer consists of ‘.java’ code.
Browser
Web Server
App Server/ Web Application
Collection of web resources within the web application is
called as App Server.
There are two types of Web Resources
1. Static Web Resources
2. Dynamic Web Resources
Static Web Resources
Response generated even before the request is sent is called
as Static web resource.
Ex: Wikipedia (coke)
Any web application which consists of only static resources
is called as Static web application.
Note
To develop Static Web Application only HTML is enough.
Dynamic Web Resources
Response generated at the time of request is called as
Dynamic web resources.
Ex: Internet Banking, (biryani)
If any web application contains at least one dynamic web
resource it is termed as dynamic web application
Note
To develop Dynamic Web Application we use Servlet, Spring
Boot (Automation frame work), etc.
Database
It is a type of software which is used to store data in the
form of tables.
Ex: Oracle, My SQL, No SQL, Sybase, Mongo DB etc.
JDBC
JDBC stands for Java Data Base Connectivity.
It is used to connect java object with the database
It is a collection of Java API’s.
Servlet
It is a collection of J2EE (Advanced Java) API’s which is
used to develop dynamic web application.
It is also used for mapping between HTML and java files.
Layers of Web Application
Web URL
- Web Uniform resource locator (URL) is used to identify specific web resource within the web application.
- Every application will have a unique address in the form of URL.
- Maximum number of characters in a Web URL is 200.
Syntax
Protocol: //Domain Name: Port number/ Resource Path? Query
String # fragment Id
Protocol
- When one application wants to exchange information with another application, there needs to be a common language which both the applications understand, hence we use protocol.
- Protocol acts as a common language between two applications (in our case browser and server).
- It is a set of rules or instructions.
- Protocol is optional information in the web URL.
Types of Protocol
- HTTP - Hyper Text Transfer Protocol
- HTTPS - Hyper Text Transfer Protocol Secured
- SMTP - Simple Mail Transfer Protocol
- FTP - File Transfer Protocol
Domain Name
It is used to identify specific computer/ server with in a
network.
Domain name can be either computer name or IP address.
It is mandatory information present in the web URL.
Port number
It is used to identify specific application within a
computer.
It is optional information present in the web URL.
Ex:
|
Web logic |
JBOSS |
http |
8080 |
80 |
https |
8443 |
443 |
Resource Path
It is used to identify specific web resources within a web
application.
It is optional information present in the web URL.
Query string
Query string always brings with ‘?’. It is always return
using name = value pair.
We can have any number of name value pair separated by
‘&’.
Fragment Id
It is used to identify specific fragment or section.
Types of languages
- Development language - C, C++, C#, Java, Ruby
- Scripting Language (Validate) - Python(Modules), JavaScript (angular JS, React JS), Visual basics, Shell script
- Other Language - XML, JSON, XSD, DTD, HTML
XML
- XML means Extensible Mark-up Language.
- XML is a mark-up language used to store and transport the data between two applications.
- XML is an extension of HTML.
- It is a strictly typed language and hence case sensitive.
- XML is platform/ language/ technology independent.
- XML is a collection of user defined or customized tags.
- In XML tags are also referred as elements.
- XML follows Tree structure.
XML structure
<root> <child> <subchild> </subchild> </child> </root> |
Ex:
<StudentDetails>
<Name>
Sai </Name>
<DOB>
29-12-95 </DOB>
<Ph>
8247802033 </Ph>
<Gender>
Male </Gender>
</StudentDetails>
XML follows Tree structure
- It consists of one root element which is a parent of all the child and sub-child elements.
- XML tags or elements have to be properly nested or looped.
- They cannot contain spaces.
- They should always begin with a letter or an underscore ‘_’.
XML attributes and elements
Anything which includes start tag, value and end tag is collectively
called as one element.
Any data which is declared in the start tag of an element is
called as Attributes.
Attributes must be written always in Name = “value” pair.
Ex-1:
<student>
<Name>
Sai </Name>
<sal>
</sal>
</student>
Ex-2:
<student Name =” ”>
<sal>
</sal>
</student>
- In example1 name is written as an element.
- In example2 name is written as Attribute.
XML entity references
Some characters in XML has a special meaning. For example
‘<’ is used to denote the start tag of an element. Hence we use XML entity
references.
< |
< |
> |
> |
! |
" |
‘ |
' |
& |
& |
Ex: <emp> sal<1000 </emp>
XML Parser
- JAXB is a parser tool used to convert java to XML and vice versa.
- Requester is a parser tool used to convert python to XML and vice versa.
- The process of converting java to XML is called as Serialization/ Marshalling.
- The process of converting XML to java is called as De-serialization/ Un-Marshalling.
JSON
- JSON stands for JavaScript Object Notation.
- It is used to store and transport the data between two applications.
- JSON is a very light weight language. (Name: value pair)
- JSON support various datatype.
- JSON is an extension of JavaScript. Hence it looks similar to JavaScript.
- JSON is very very popular.
- JSON data can be parsed very easily.
- JSON is supported by most of the browsers.
REST – Representation State Transfer
REST – Representation State Transfer
JSON structure
{
“name1”: value1,
“name2”: value2
}
{
“name1”: value1,
“name2”: value2
}
Example
{
“name”: “sai”,
“age”:
}
{
“name”: “sai”,
“age”:
}
Note
· JSON follows MAP structure.
· JSON data is written using name: value pair. Name should be always enclosed within double quotes and the value depends on the datatype.
Each name: value pair must be separated using coma ‘,’.
· Curly brasses ‘{}’ are used to create an object.
· Square brasses ‘[]’ are used to create an array.
JSON Parser
· Jacson/ Jersy/ Jacsrc are the parser tools used to convert java to JSON and vice versa.
· Requester is a parser tool used to convert python to JSON and vice versa.
· The process of converting java to JSON is called as Serialisation/ Marshalling.
· The process of converting JSON to java is called as De-serialisation/ Un-Marshalling.
JSON datatype
In JSON the values must be one of the following datatypes.
1.
String
2.
Number
3.
Boolean
4.
Null
5.
Array
6.
Object
7.
Object Array·
String values must be written using double
quotes (“ “).
·
Number can be any integer or a decimal.
·
Boolean is either true or false.
·
Null values are always null.
·
Array values must be enclosed with square
brasses.
1. String
2. Number
3. Boolean
4. Null
5. Array
6. Object
7. Object Array
· Number can be any integer or a decimal.
· Boolean is either true or false.
· Null values are always null.
· Array values must be enclosed with square brasses.
Different between XML and JSON
JSON |
XML |
|
|
Service Oriented Architecture (SOA)
Presentation layer |
|
Business layer |
|
Database |
GUI |
|
Source
Code |
|
Data |
Functional testing Manual Automation |
|
API Testing 1.WBT/ Unit testing 2.Web service testing a. SOAP web service testing. b. REST web service testing |
|
Database testing ETL (Extract/ Transform / Load) |
API Testing
Unit Testing/ WBT
Testing the application in business layer (source code) with the help of another program is called as WBT/ Unit testing.Web Service
Web service is a mechanism where two applications exchange information
with each other irrespective of their underline technology.
Web service helps two applications exchange information
without sharing the source code and the database data.
All web services are API, all API’s are not the web
services.
Note
All web services are exposed via API.
Why Web Service Testing?
SOAP web service testing
What is SOAP?
What is SOAP web service testing?
SOAP web service testing tools
REST web service testing
What is REST?
- REST stands for Representational State Transfer.
- It is an architectural style.
- It is used to represent the state of the request.
REST web service testing tools
Difference between SOAP and REST web services
SOAP |
REST |
|
1. Representational State
Transfer 2. REST is an Architectural
Style. 3. REST does not define too
much standards. 4. REST API’s are exposed via
URI. 5. REST permits JSON, XML,
HTML, JavaScript, and test. 6. REST can use SOAP as well
since it is a concept. 7. We have to inherit few
security measures like Bearer token and Oauth. 8. REST is more preferred than
SOAP. |
Advantages of web services
Http structure
|
http request |
|
http response |
|
Header |
HTTP method Web URL Content type Cookies |
M |
Status code Response time Content- type Cookies |
Header |
Body |
Form –data |
|
Actual – data |
Body |
Http method
Http method is mandatory information present in the header of http request.
POST |
Use to create a resource |
GET |
Use to read the resource |
PUT |
Used for complete updation of
the resource |
PATCH |
Used for partial updation |
DELETE |
Use to delete the resource |
Content- type
Ex
- Application/ JSON
- Application/ XML
- Application/ text
- Application/ HTML
Cookies
It is the additional information.
Status code
200 – Successful
300 – Re-direction
400 – Client side server
500 – Server side error
HTTP status codes
Level 200 (Success) |
|
Level 400 |
|
Level 500 |
200 : Ok 201 : Created 203 : Non-Authoritative information 204 : No content |
|
400 : Bad request 401 : Unauthorized 403 : Forbidden 404 : Not found 409 : Conflict |
|
500 : Internal Server error 501 : Not Implemented 502 : Bad Gateway 503 : Service Unavailable 504 : Gateway timeout 599 : Network timeout |
Response time
Total time taken to send the request, process the request and
given back the response is called Response time.
Actual- data
If is the actual response provided by the server.
From –data
Data collected from browser to the server is called
From-date.
Ex: Browser sending code details to the server.
Postman
Postman is a API client tool.
API
Development team |
API Testing team |
Monitor API Publish API
document Mock Documentation |
GUI Open source Easy to send
request. Snippets for
validation Collections (
end – to –end ) Command line
execution using Newman Easily
integration with Jenkins. |
No comments:
Post a Comment