The MongoDB Query tool sends a query to a MongoDB database and returns the JSON-format results from that query. JSON tools such as JSON Data Banks and JSON Assertors can be added as "outputs" to MongoDB Query tools in order to display and/or validate the query results.

Requirements

  • MongoDB versions 2.6, 3.0, 3.2, 3.4, and 3.6 are supported.
  • This tool requires SOAtest/Virtualize 9.5 or later.

Installation

The tool can be installed from the UI or the command line.

UI Installation

  1. Choose Parasoft> Preferences.
  2. Choose System Properties and click Add JARs.
  3. Browse to the mongodbquerytool.jar file and click Open.
  4. Apply the changes and restart SOAtest/Virtualize.

Command Line Installation

Add the mongodbquerytool.jar file to the system.properties.classpath property in your localsettings properties file. For example:

system.properties.classpath=<path to jar>/mongodbquerytool.jar

Usage

You can add MongoDB Query tools as standalone tools with the SOAtest Add Test wizard. You can also add them as Virtualize provisioning action tools. Before the tool can be run, you must configure the MongoDB connection, as well as the query you want to run. Once a MongoDB Query tool is added to a suite, you can add any JSON tool as an output.

Configuration

You can configure the following settings.

Connection Settings

HostSpecifies the host of the MongoDB server to query. If empty, the default value will be used. Default is localhost.
PortSpecifies the port of the MongoDB server to query. If empty, the default value will be used. Default is 27017.
Authentication Mechanism

Specify the authentication mechanism used to connect to the MongoDB server. The following values are acceptable:

none: Use this value if no authentication mechanism is required.

server-defined: Use this setting to use the default authentication method configured on the mongoDB server (SCRAM-SHA-1 or MONGODB-CR).

LDAP: Use this setting to authenticate using an LDAP service, such as Active Directory or OpenLDAP.

UsernameSpecifies the username with which to authenticate to a MongoDB database that uses authentication.
PasswordSpecifies the password with which to authenticate to a MongoDB database that uses authentication.
Authentication DatabaseSpecifies the authentication database to use. If empty, the default value will be used. This setting is ignored when the authentication mechanism is set to LDAP. Default is admin.
Use SSLSpecifies whether SSL should be used when connecting to the MongoDB server. If empty, the default value will be used. Default is false.

Query Settings

DatabaseSpecifies the name of the MongoDB database to query
CollectionSpecifies the name of the MongoDB collection to query.
QuerySpecifies the query in the strict mode of the MongoDB Extended JSON language (see the MongoDB Documentation for details). If empty, the default value will be used. Default is all documents.
ProjectionSpecifies the projection in the strict mode of the MongoDB Extended JSON language (see the MongoDB Documentation for details). If empty, the default value will be used. Default is all fields.

Example Query 1

The following query returns all the items in the product collection.

Example Query 2

The following query returns all fields of product id 101 from the products collection.

Example Query 3

The following query returns only the sku field for product id 101 from the products collection.

Using Output Tools to View and Process Query Results

Any tools that operate on JSON can be added as outputs to a MongoDB Query tool. For example, you might want to add a JSON Data Bank to view the results and/or a JSON Assertor to validate the results. To add an output:

  1. Right-click the appropriate MongoDB Query Tool node, then choose Add Output.
  2. In the Add Output dialog, choose a JSON tool in the right pane and click Finish.

After the MongoDB Query tool is executed, output will be passed to the chained tool. You can then perform additional tool configuration as needed (e.g., to specify assertions, extractions, etc.).

Third-Party Content

This plugin includes items that have been sourced from third parties as outlined below.

Additional license details are available in this plugin's licenses folder.

  • No labels