Sample Plugin

Applies to ReadyAPI 3.56, last modified on October 29, 2024

This topic provides a small example of performing two main things:

  • Creating a basic project based on a sample plugin and trying it.

  • Customizing the plugin action, adding features, and installing the updated plugin.

The Process

  • A Basic Project

  • Create a plugin project – mvn archetype:generate.
    1. Build and package – mvn install.
    2. Install the plugin file, add it to your ReadyAPI.
    3. Try out the plugin, make sure it works.
    4. Remove the plugin again, we will replace it with the customized version.
  • Customize the Plugin

  • Open the project in your favorite java development environment.
    1. Change the PluginAction.java class.
    2. Edit metadata to reflect changes.
    3. Build and package – mvn install.
    4. Install the plugin file, add it to ReadyAPI.
    5. Try out the plugin, make sure it works.

A Basic Project

To create a basic plugin, use the maven archetype to generate a basic plugin project.

1. Browse to the project directory (where you want to create the plugin project).

2. Open the command prompt.

3. Run the command.

Note: Line breaks are added for readability. The command must be written on a single line.

mvn archetype:generate
-DarchetypeGroupId=com.smartbear.maven.archetypes
-DarchetypeArtifactId=soapui-plugin-archetype
-DarchetypeCatalog=http://smartbearsoftware.com/repository/maven2

This will download and install the maven archetype and start the generation of the plugin project. You will be prompted for a number of properties – set these as follows:

- groupId: "com.mycompany"
- artifactId : "my-plugin"
- version : "1.0.0"
- package : <empty >
- language : "java"
- type : "Action"

The default project is generated by maven:

generate-from-archetype

4. Open the my-plugin directory.

5. Open the command prompt.

6. Run the command:

mvn install

Maven builds the plugin and packages it for installation:

Build with Maven
Installing the Plugin

Use the Plugin Manager to install the plugin file.

See Install Plugin From File for more information.

Trying the Plugin

To see the installed action, right-click an open project in your ReadyAPI workspace.

The plugin action is at the bottom of the menu:

initial-plugin-menu-action

Removing the Plugin

Use the Plugin Manager to uninstall the plugin file.

See Remove plugin for more information.

Customizing the Plugin

The basic sample plugin does not do anything useful, it only displays a 'hello' message. We now want to change the plugin to perform a search in our project, and open the list with the search results in the selected project.

Opening the Project

Open the project in your java development environment.

Find the Maven generated file - PluginAction.java.

generated-plugin-action

The default implementation of the perform method just shows a "Hello from..." message in a pop-up window.

Changing the Action

Let's change the perform method to

  • prompt for a regular expression search string (UISupport.prompt);

  • do a recursive search through all items in the selected project (findItems);
  • match item names using the search string;

  • display the results in ModelItemListDesktopPanel (UISupport.showDesktopPanel).

search-plugin-action

We have changed some of the metadata in the constructor.

The generated PluginConfig.java file has been updated accordingly:

plugin-config

And, we have also changed the metadata in the pom.

<name>ReadyAPI Search Plugin</name>

<artifactId >readyapi-search-plugin</artifactId>

<groupId >com.smartbear.soapui.plugins</groupId>

Building the Plugin

We need to build a plugin file to be installed:

  1. Open the my-soapui-plugin directory.

  2. Open the command prompt.

  3. Run the command:

    mvn install

Maven builds the plugin and packages it for installation.

Installing the Plugin

Trying Out the Plugin

With the plugin installed, you now have a new option on the context menu:

search-menu-item

It prompts as follows when selected:

search-prompt

It uses the specified regular expression to find items in the selected project and to display them:

search-result

Double-clicking an item in this window opens the corresponding desktop panel for editing.

Highlight search results