We can create a JSON Object using a Map in Java. You must note here that I am using the word “JSON Object”. A JSON Object is a key-value pair and can be easily created using a Java Map. A Map in Java also represents a collection of key-value pairs. Start with a very simple …
Continue reading Creating JSON Object Request Body Using Java MapRestAssured
JSON stands for “JavaScript Object Notation” which is a lightweight , language independent and self describing format in text for data storing and interchange. JSON is easy to read, write and create for humans which makes it famous over XML. JSON was derived from JavaScript but now it is supported by many languages. A file …
Continue reading Introduction To JSONWhen a request is sent to a server, it responds with a response. The amount of time taken between sending a request to server and retrieving a response back form a server is called Response Time. An API must be faster. As a part of API testing, we must check the response time as well. …
Continue reading Get & Assert Response Time Of RequestYou may required to save API response in to an external file like text or JSON etc file for future reference or as a proof. In this post, we will concentrate on saving response in a text file. Rest Assured provides below methods to get response as:- As byte array :- asByteArray() As input stream …
Continue reading Writing Response In A Text FileSuppose you have a request payload (JSON or XML) in a file and you required to directly send that file as a payload to request in stead of reading it first and then passing. Sending file as a payload directly is a good idea when you have static payloads or minimal modification. “body()” method of …
Continue reading How To Send A JSON/XML File As Payload To RequestWriting response into a JSON file Rest Assured provides below methods to get a response as:- As byte array :- asByteArray() As input stream :- asInputStream() As string :- asString() All the above methods output can be used to write into a JSON file. Example program Output Refresh the project folder if you are using …
Continue reading Write API Response In A JSON FileStatic members of a class When we use a “static” modifier with the declaration of a member of a class is called a static member of that class. It is also called a class member. We can use static with a variable, method, inner class, and blocks. Static members are associated with the class, not with …
Continue reading Reason for Static Import In RestAssuredport is a communication endpoint where a service is available. For example if we install Jenkins on a server or local , we start it at a specific port and using that port we access Jenkins. So if you have some services running on a specific port, you need to pass that in URI so …
Continue reading Default Host And Port In Rest AssuredWhy RequestSpecification? Observe the below lines of codes carefully. You will find that we have some common statements in both @Test methods after given() method call. Above we have only two tests but in real-time you may have many. A group of tests will have some common specifications to create a request. Following the DRY …
Continue reading RequestSpecification – How The Request Will Look LikeWe need to pass booking id which you want to delete in URI. E.g. https://restful-booker.herokuapp.com/booking/1 where “1” is booking id. Authentication token need to pass as cookie. Cookie name is “token” and value is generated auth token. ‘Cookie: token=<generatedToken>’. You don’t required to pass body to DELETE request. Let’s see existing details of a Booking …
Continue reading Write First DELETE Request In REST Assured