Load Property File
You can load properties from a .properties file using Groovy script and use property names in request URL, headers and payload.
If you want to run the same service on another server for example, you just update the Sample.properties file with new server name and run the service.
You do not need to change service URL. You can add any number of properties within the file and use them in request URL, headers and payload.
It saves your time.
Also, you can create a properties file for each environment as DEV.properties, QA.properties, Stage.properties and Production.properties and so on.
Step 1: Create Sample.properties file in a folder C:/temp.
SERVER_NAME = http://jsonplaceholder.typicode.com
PORT_NUMBER = 8080
Step: 2 Add a Groovy Script with the following.
def propertyFileName = "C:/temp/Sample.properties" ;
app.importProperties( propertyFileName ) ;
Step 3: Add a REST service and replace URL with the following.
Step 4: Now Select both groovy script and service. Click on [Run Services and Scripts] button.
Step 5: At runtime, SERVER_NAME in URL is replaced with the value obtained from Sample.properties file.
Step 6: Click on Respone | Report | View Report button and see the report.
Copyright © 2016 junorestclient.com