Java Client
Overview
The NeoLoad Controller installation directory includes necessary JAR files to interact with the NeoLoad Design API.
The Java client is compatible with Java 7 and above.
Configure the Java project
To configure your Java project, it is recommended to use Maven.
x.y.z stands for the latest version of the dependency.
Maven projects
In a Java Maven project, you need to add a dependency to the Maven settings file (pom.xml) using the examples below:
- Repository
<repositories><repository><id>neotys-public-releases</id><url>http://maven.neotys.com/content/repositories/releases/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository></repositories>- Dependency
<dependencies><dependency><groupId>com.neotys.rest</groupId><artifactId>neotys-rest-api-design-client-olingo</artifactId><version>x.y.z</version></dependency></dependencies>Non-Maven projects
If your project is not developed using Maven, it is necessary to include the JAR files available in the \api folder of the NeoLoad installation directory:
- in the <install-dir>\api\Design API Client\Java folder
- in the <install-dir>\api\Common\Java folder
Create the Java Design API client
import com.neotys.rest.design.client.DesignAPIClient;import com.neotys.rest.design.client.DesignAPIClientFactory;import com.neotys.rest.design.model.StartRecordingParams.StartRecordingBuilder;public class Main {public static void main(String[] args) throws Exception {final String url = "http://localhost:7400/Design/v1/Service.svc";final DesignAPIClient client = DesignAPIClientFactory.newClient(url);}}UserPathBuilder Java helper
A Java class is available to ease the creation of a NeoLoad User Path. Here is an example of Java code using this helper:
import com.neotys.rest.design.builder.JSONDefinitionBuilder;import com.neotys.rest.design.builder.UserPathBuilder;import com.neotys.rest.design.model.element.ElementType;public class Documentation {public static void main(String[] args) throws Exception {final String url = "http://localhost:7400/Design/v1/Service.svc";final DesignAPIClient client = DesignAPIClientFactory.newClient(url);// Create a UserPath with name "myUserpath"final UserPathBuilder builder = new UserPathBuilder("myUserpath");// Put the cursor to the Actions containerbuilder.moveToActions();// Create a Transaction "myTransaction1", insert it in the Actions container and put the cursor inside it.builder.addChildAndMoveTo(ElementType.TRANSACTION.key(), new JSONDefinitionBuilder().name("myTransaction1").build());// Create a Delay with 5 secondes duration and insert it in the Transaction "myTransaction1"builder.addChild(ElementType.DELAY.key(), new JSONDefinitionBuilder().put("Duration", "5000").build());// Go up one level (out of the "myTransaction1" elementbuilder.moveToParent();// Create a Transaction "myTransaction2" and insert it after "myTransaction1"builder.addChild(ElementType.TRANSACTION.key(), new JSONDefinitionBuilder().name("myTransaction2").build());// Build the full User Path structure and add it to the projectbuilder.build(client);}}Here is the result in the NeoLoad project:
Home