Table of contents
1.
Introduction
2.
JMS Configuration in ReadyAPI
2.1.
Adding JMS Server
2.1.1.
JMS Provider
2.1.2.
Initial ContextClass
2.1.3.
Provider URL
2.1.4.
ConnectionFactory
2.1.5.
User Name
2.1.6.
Password
2.1.7.
Additional JNDI properties
2.2.
JMS Dialog
3.
JSON Path reference in ReadyAPI
3.1.
JSON path Notation
3.2.
Expression Syntax
3.3.
Filters
3.4.
Filter syntax 
3.5.
WildCards
3.6.
Assumptions
3.7.
Examples
4.
Frequently Asked Questions
4.1.
Differentiate between SoapUI and ReadyAPI?
4.2.
Explain "JMS as a protocol"?
4.3.
Is ReadyAPI a tool for automation?
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

JMS Configuration and JSON Path reference in ReadyAPI

Author Ashish Sharma
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

The Java Message Service API is a communication standard that allows Java Platform Enterprise Edition (Java EE) application components to generate, transmit, receive, and read messages. It provides loosely connected, dependable, and asynchronous distributed communication.

In this article, we will discuss the introduction to JMS, JMS configuration in ReadyAPI, and JSON path reference in ReadyAPI.

JMS Configuration in ReadyAPI

We can easily configure a connection to the JMS provider from ReadyAPI without using any extra intermediate processes.
We need to configure the JMS in ReadyAPI. There are two methods through which we can configure:

▶️The first method is via creating a JMS connector plugin. Plugin holds all the JMS client libraries and provides the default values for setting up the connection. You need to create a connector plugin and to do so click on the link.

▶️The second method uses the JMS broker which provides the JMS client libraries. Now for configuration, we need to follow the below steps:

🔺In the first step, you need to copy the .jar files which contain the client libraries for the JMS providers to <ReadyAPI>\bin\ext folders.

🔺To download the library files follow the respective link of the library provider JMS provider.

🔺But it has a limitation, you need to configure it manually because ReadyAPI is not able to identify the default values.

Adding JMS Server

You should mention a JMS Server to use a direct connection with a JMS provider. You will do the same in the JMS dialog which we discuss in the upcoming section of the article.

When you create a JMS server, ReadyAPI displays the JMS configuration window, where you can configure the server's settings. ReadyAPI will use the connector libraries to connect to the specified server via JMS.

adding jms server

JMS Provider

It provides the list of preconfigured JMS providers. Here we are installing the JMS connector plugin for the JMS providers so that it will be visible on the list.

Initial ContextClass

The initial Context class is the class that will be used to create an IntialContext Object for the JMS.
When you use the JMS connector plugin, JMS will provide you with a default value that cannot be changed, and if you want to change it you will need to configure the JMS manually.

🔺Apache ActiveMQ : org.apache.activemq.jndi.ActiveMQInitialContextFactory

🔺IBM WebSphere MQ: you will get the values from the Initial Context Factory property when you configure the WebSphere MQ installation and how the context class is configured.

🔺Oracle Weblogic: weblogic.jndi.WLInitialContextFactory

🔺Tibco CMS: com.tibco.tibjms.naming.TibjmsInitialContextFactory

You can easily find the initial context class name in the JMS providers.
 

Provider URL

JMS Connector plugins help us set the selected providers' default value. It is the URL of the JMS server.
Here are some context classes for popular JMS providers:

🔺Apache ActiveMQ: tcp://<hostname>:61616

🔺IBM Websphere MQ: It specifies the value you get from the provider's URL property.

🔺Oracle WebLogic: t3://<hostname>:7001 

🔺TIBCO EMS: tibjmsnaming://<hostname>:7222
 

ConnectionFactory

Most JMS providers allow you to choose the name during the provider's initial setup. The JMS Connector plugin sets a default value for the given provider.
Here are some context classes for popular JMS providers:

🔺Apache ActiveMQ: ConnectionFactory

🔺IBM Websphere MQ: It specifies the value which you get from the ConnectionFactory.
 

User Name

The user's name is used to authenticate with the JMS broker.
 

Password

The user's password is used to authenticate with the JMS broker.
🔺 If you want to dynamically provide the login and password to JMS settings, save them in project properties and use property expansions.
🔺 If you want to provide the login and password to JMS settings dynamically, save them in project properties and use property expansions 
🔺 To use it click the ellipsis button next to the User Name or Password field and select the appropriate project property. 

password

Some JMS services (such as WebLogic, webMethods, and TibcoJMS) need you to create additional JNDI properties with your login and password:

java.naming.security.principal = <username>
java.naming.security.credentials = <password>

 

Additional JNDI properties

We will require custom JNDI attributes depending on the JMS provider b Because the ActiveMQ JMS broker provides a fully working JNDI server. You have to use the attributes to give JNDI context for your requests. We can do this by including custom properties such as a queue in JMS. 

jms endpoint

JMS Dialog

A list of JMS servers is available in the JMS window. We specify the servers when we configure a JMS virtual service or specify an endpoint for the JMS Requests test phase.

JMS dialog

Click on the JMS button to open the dialog box.

JMS Button

To remove, add or configure JMS servers, carefully use the items of the dialog’s toolbar on the top of the page:

cofigure jms

JSON Path reference in ReadyAPI

JSONPath is a JSON query language that allows you to refer to the structure of a JSON object in the same way that XPath expressions can do for XML documents. JSONPath expressions can be used in ReadyAPI to refer to specific objects or elements in requests and responses, which is useful for assertions or property expansions that operate with JSON objects.

JSON supported versions

ReadyAPI 1.4.1 – 2.2 – JayWay JSONPath 2.0.0

ReadyAPI 1.1 – 1.4.0 – JayWay JSONPath 0.9.1

ReadyAPI 2.3 - 3.40.2 – JayWay JSONPath 2.4.0

ReadyAPI 3.41.0 and later – JayWay JSONPath 2.7.0
 

Ways to use JSONPath in ReadyAPI

Testing options Description
Functional Tests

Use JSON objects as data sources.

Transfer properties.

Security tests Get the properties to use these in security scans.
Virtual services Get request properties to easily compare them with a baseline by the selected dispatch strategy.
Overall ReadyAPI

Retrieve the data to use in the property expansion.

Create various assertions.

JSON path Notation

Two types of JSONpath Notation describe the path to the single element or set of elements in a JSON structure. 

  1. Dot Notation: $.store.book[0].title
  2. Bracket Notation: $['store']['book'][0]['title']

The prefix $ character represents the array or the root object which is optional and can be removed easily. $.object.element and object.element both are the same expressions.

Expression Syntax

                    Expression                   Description
$ It is the array or the root object.
Object.property['object'].['property'] It selects the property in the object.
[n] It selects the nth element from an array with the starting index 0.
[n1,n2] It selects the n1 and n2 array items and returns a list.
..property It Performs the deep scan for the specified property in all available objects and always returns a list, even if the single property matches.
* All the elements in an object or array are selected independently of their names or indexes.

[n1:n2]

[n1:]

Selects the array items from n1 to n2. The n2 element will not be included in the selection. Remove the n2 from the expression to select the array items from n1 to n2 and then return the list.
[:n] It selects the first n items from the array and then returns the list.
[-n:] It selects the last item of the array and then returns the list.
[?(expression)] It selects all the elements in the object that matches the specified filter and then returns the list.
@ It is used for filtering the expressions. 

Filters

We apply the filters to JSON objects and arrays to get the subset of items that match the filter conditions.

To create the filter expression, we need to place the filter after the path and then enclose it in the square brackets. 

For example:

$.ninjasstore.book[?@.price>15)]

@ character is used to represent a current array object and array item to process.

Now to refer to the property located outside of a current object, we will add a $ character to filter:

$.ninjasstore.book[?(@.price>$.expensive)]

We can also create the expression that can match all the items that possess a specific property:

[?(@.isbn)] //it matches all the jsbn property.

Filter syntax 

                      Operator                        Description
==

Equal to operator is used to use the string values in the expression.

Expression is enclosed in the single quotes. For example,

[?(@.color==’red’)].

 

Remember that

 

In ReadyAPI 2.3.0 and later: 1 is not equal to ’1’. But in ReadyAPI previous versions than 2.3.0 1 is counted as ‘1’.

!=

Not equal operator is used to use the string values in expression.

Expression is enclosed in single quotes.

For example,[?(@.color!=’red’)].

> Greater than
< Less than
>= It denotes greater than or equal to.
<= It denotes less than or equal to.
=~

We will use [?(@.color=~/dog.*/i)] to find all the items that have the names starting with dog (including dog, and so on).

But this is not available in ReadyAPI versions before 1.4.1.

!

It denotes the negative filter. For example, let’s use [?(!@.color)] to match all the items that does not contain the color property.

But this is not available in ReadyAPI versions before 1.4.1.

&&

It denotes the logical AND operator.It  allows you to combine the multiple filter expressions, for example:

[?(@.type==’ninja-shirt’&& @.amount>5)]

||

 

It denotes the logical OR operator.It allows you to combine the multiple expressions, for example:

[?(@.type==’ninja-shirt’|| @.amount>5)]

 

But this is not available in ReadyAPI versions before 1.4.1.

in

It matches the items whose property has one of the specified values, for example:

[?(@.size in[‘S’,’L’])]

But this is not available in ReadyAPI versions before 2.3.0.

 

nin

It matches the items whose property does not have one of the specified values.

But this is not available in ReadyAPI versions before 2.3.0.

subsetof

It matches the items whose property has the value which is the subset of the specified array. For example:

[?(@.sizes subsetof [‘S’,’M’,’L’])]

size

It matches the items whose property ( array or string) has the specified size.

But this is not available in ReadyAPI versions before 2.3.0.

empty

It matches the items whose property (array or string) is empty. For example:

[?(@.sizes empty true)]

But this is not available in ReadyAPI versions before 2.3.0.

WildCards

Wildcards are used to pick all elements available in an object or array. JSONpath indicates the wildcards with the * symbol. It can be used in both basic expressions and those with filters. For example:

$.store.*

 

The above expression returns all the properties of the object object.

The above option is disabled by default for ReadyAPI dialog boxes that allow you to use JSONPath expressions, so you should activate it before using wildcard expressions. for example:

Assumptions

🔺JSONPath expressions does not returns a single element, but also contains the list of matching elements. For example,

Example

{
  "company_name": "JMS configuration in readyapi",
  "shops": [
    {
      "address": "delhi",
      "phone": "555-120-1234"
    },
    {
      "address": "Mumbai",
      "phone": "555-130-1234",
    }
  ]
}

 

You can call the JSONPath expression to fetch all the phone numbers, which look like this:

shops[*].phone

 

Note: Make sure wildcards enables to use the expression in ReadyAPI.

You will receive the list that consists of two numbers:

[555-120-1234, 555-130-1234]

The above data is not in the JSON array, but the list of items where the [] characters indicate a list's start and end.

🔺When we use  assertions that compare the property value to the list of values, and specifies the list of expected values that are enclosed in [] and separated by the comma and a single space:

[beverages, 20, true, ["bottles", "can"], {"taste": "banana"}]

 

Do not enclose the separate strings (like beverages) in the quotes, unless the quotes are the part of  value – for example, use "Ninjas" to match "\"Ninjas\"".

🔺Do not use the double quotes for every element names and values. Use only single quotes.

🔺JSONPath expressions may return either an array or a single value, depending on expression syntax:

🔻Expression which contain filters ([?(filter)] and array ([start:end] always returns an array, even if the resultant array contains the single item. For example: $.section.fields.item[?(@.name=='Coding Ninjas')].fldValue
 

The above code will return an array if the fldValue element contains only one value. To get the above value, add the index to expression:

$.section.fields.item[?(@.name==JMS configuration in readyapi)].fldValue[0]

 

🔺If the object has two or more properties, object wildcards will return an array. Otherwise, it will return the single property's value (this value will keep the initial type). Suppose you need to obtain the characteristics of the following object:

Example

{
  "section": {
    "first_subsection": {
      "name": "JMS configuration in readyapi"
    },

    "second_subsection": {
      "name": "JMS configuration in readyapi1",
      "contains_images": true
    }
  }
}

 

The below expression will return a titular string:

$.section.first_subsection.*
// The first_subsection element has the single property

The below expression will return the array:
$.section.second_subsection.*
// Returns ["name": "JMS configuration in readyapi", "contains_images": true"]

 

🔺The array wildcards (arr[*]) executes differently depending on the ReadyAPI version:

🔻In ReadyAPI 2.3.0 and later: Array wildcards always return the array. For the above example, the following expression:

$.section.first_subsection[*]

 

– will return an array:

["name": "JMS configuration in readyapi"]

 

🔻ReadyAPI 1.4.1 - 2.2.0- Array wildcards return an array only if the original array contains more than two entries in ReadyAPI 1.4.1 - 2.2.0. The results for arrays with a single item may vary depending on the type of the item.

For example, for the following objects:

{
  "section": ["content"],
  "second_section": [ {"number": 5} ]
}
the JSONPath expressions will be as follows:
$.section[*] = content // A string
$.second_section[*] = [ {"number": 5} ] // The array

Examples

We will see some of the examples in which we will use the modified version of JSON:

{
  "store": {
    "book": [
      {
        "category": "books",
        "author": "Joseph Toynbee",
        "title": "Data Structures",
        "price": 110
      },
      {
        "category": "languages",
        "author": "Aneirin",
        "title": "C++",
        "price": 170
      },
      {
        "category": "food",
        "author": " Joyce",
        "title": "foody doody",
        "isbn": "9788804677628",
        "price": 159
      },
      }
    ],
    "bicycle": {
      "color": "black",
      "price": 255
    }
  },
  "expensive": 110
}

 

▶️To retrieve all the properties of store object.

$.store.*

 

▶️find the bicycle color.

$.store.bicycle.color

 

▶️find the price of all items.

$.store.. Price
$..price

 

Result: [110,170,159]
 

▶️ find the information of all the books.

$.store.book[*]
$..book[*]

 

▶️ find the title of the books.

$..book[*].title

 

Result: [data structure,C++]

Frequently Asked Questions

Differentiate between SoapUI and ReadyAPI?

SmartBear's SoapUI is an open-source solution for automated web service testing. It can be used to automate functional and security API tests while ReadyAPI is an API ready platform that contains a test module for the next generation of SoapUI.

Explain "JMS as a protocol"?

AMQP is a protocol while JMS is an API. JMS does not require a protocol between the JMS client and the JMS message server. The JMS client implements the JMS API and can communicate with the JMS server through any protocol.

Is ReadyAPI a tool for automation?

ReadyAPI is an API automation testing solution for REST and SOAP APIs. ReadyAPI is used to evaluate web services, and focuses on the efficiency and usability. ReadyAPI also provides extensive web services testing.

Conclusion

In this blog, you learned JMS Configuration and JSON Path reference in ReadyAPI. All the important topics related to JMS Configuration in readyapi and JSON Path reference in ReadyAPI were covered in detail.

Also, do refer to other API testing-related articles:

Check out this problem - Root To Leaf Path

Please refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. And also, enrol in our courses and refer to the mock test and problems available. Have a look at the interview experiences and interview bundle for placement preparations.

Please upvote our Managing Test Items in ReadyAPI blog if you found it helpful and informative!

Happy learning!

Live masterclass