Java

How to add java sdk into your application

1. Installing java-SDK package

HyperTest's mvn packages are hosted on a github private MVN registry To Install and use HyperTest's java-sdk package in your application, we will do the following steps:

  1. Create MVN_TOKEN - The Hypertest Team share this with you.

  2. Add Repository Configuration in pom.xml

    1. Define Properties in pom.xml file

    2. Add the Repository in pom.xml file

  3. Install HyperTest's java-sdk package

Add the following content in your pom.xml

pom.xml
<properties>
    <MVN_USERNAME>hypertestcustomers</MVN_USERNAME>
    <MVN_TOKEN>[YOUR_MVN_TOKEN]</MVN_TOKEN>
</properties>

<repositories>
    <repository>
        <id>github</id>
        <url>https://${MVN_USERNAME}:${MVN_TOKEN}@maven.pkg.github.com/hypertestco/autoqa_v2_java</url>
    </repository>
</repositories>

Run the following command

mvn clean install

2. Initializing SDK

2.1 Adding SDK in code

  • Initalize hypertest java sdk in public static void main function of your service

  • <HT_SERVICE_ID> is the identifier that we created in Adding your first service section

This needs to happen as early in your app as possible.

HypertestAgent.start("<HT_SERVICE_ID>", "<YOUR_SERVICE_NAME>",  "<API_KEY>", "<LOGGER_URL>");

2.2 Mark app as ready

Call this method after SpringApplication.run when the app is ready to receive traffic, it indicates that tests can be started (This is important ONLY FOR REPLAY mode).

// Rest Application code...
System.setProperty(APP_STATUS, UP_STATUS);

3. Verifying traffic is captured

Start sending http requests on your app running with hypertest sdk.

You should start seeing requests under All requests section on the dashboard

Last updated