Previous Topic

Next Topic

Book Contents

Book Index

Use Case 1: Handling an MD5 authentication

You can find the project used for this use case on GitHub here:

In This Chapter

Create a new Maven project

Configure the interface of the Advanced action

Code the behaviour of the Advanced action

Use the Advanced action in NeoLoad

See Also

How to extend NeoLoad capacities using Custom Advanced Actions

Understand the Use Cases

Set up the environment for Advanced actions

Use Case 2: Load testing a non-http protocol

Use Case 3: Sending my load test data to a third-party tool

Create a new Maven project
  1. Open Eclipse.
  2. Select File > New > Project.
  3. Choose the Maven Project wizard and click on Next.
  4. Click on Next until you reach the Select an Archetype step.
  5. Choose neotys-custom-action-archetype and click on Next.
  6. Specify the Archetype parameters and click on Finish.

You should now have a Maven project created with the following structure.

Configure the interface of the Advanced action

After this step, you will be able to configure:

Give a name and path to the Advanced action

Modify the icon of the Advanced action (optional)

The final files for this section can be found here:

Set the default input parameters

As we will be hashing a message using MD5, we only need one input parameter which is the message to hash.

Give a description to the Advanced action (optional yet highly recommended)

You can find the final version of the file on GitHub here:

The file can be found here:

Install the Advanced action in NeoLoad

Now that we have set up our Advanced action for NeoLoad, we will need to install it in order to display it.

Check the configuration in NeoLoad

The Advanced action now appears in the Actions section of NeoLoad. You can check that the name, icon and path are configured as defined in your Eclipse project.




You can now see the description you have entered in Eclipse, as well as the message parameter added to the getDefaultActionParameters() function.

Code the behaviour of the Advanced action

We have now finished interfacing our Advanced action with NeoLoad. Let’s get into the code and hash the message with MD5. We will now be working with the class in src/main/java/<package name>.

This tutorial section consists in 5 steps:

  1. Parse the input parameters.
  2. Log the input parameters for debug purposes.
  3. Execute the MD5 Hash.
  4. Provide the result to NeoLoad.
  5. Check that the Advanced action works as expected.
Parse the input parameters

Log the input parameters

This section shows how you can have your Advanced action display the values of your variables in the NeoLoad interface.

We will be doing the logging while parsing the input with the following line:

	String.format("%s: %s",temp.getName(),temp.getValue()));

We now have a section that does the parsing and the logging at the same time:

//List and initialize all the parameters
for (ActionParameter temp:parameters) {
			String.format("%s: %s",temp.getName(),temp.getValue()));
	switch (temp.getName().toLowerCase()) {
	case "message":			//If the current parameter is a message 
		message = temp.getValue();	//Initialize the message value
	default :

Execute the MD5 Hash

For this step, we will be using standard Java methods. The function to return a message with an MD5 hash is the following:

private static String MD5Hash(String message) {
//Hashes a messages through MD5

try {
	MessageDigest md = MessageDigest.getInstance("MD5");
	byte[] array = md.digest(message.getBytes());
	StringBuffer sb = new StringBuffer();
	for (int i = 0; i < array.length; ++i) {
			toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
	return sb.toString();
} catch (NoSuchAlgorithmException e) {
	return null;

Let’s now call that function in the execute() function. We will simply call it with:

String hashedMessage = MD5Hash(message);

Provide the result to NeoLoad

Now that we have hashed the message, we need to provide the result to NeoLoad. This can be done with the line:

				String.format("Hashed message: %s", hashedMessage));

The final file is here:

Check the behavior of the Advanced action



Use the Advanced action in NeoLoad

Now that we have checked our Advanced actions works as expected, we can use it in NeoLoad as any other request. We will see how to:

Using the variable

We will create here a list called "Message" with:



Extracting the response

As we are performing an MD5 Hash on a message, we will probably need to use the result in a script. In order to do that, we will need to extract that result in NeoLoad variable, which we will be able to use later on.



You can now create a variable extractor as explained in Variable extractors.

Get statistics from the Advanced action executions

For more information about using Advanced actions see Use an Advanced action.