Contact Us 1-800-596-4880

Example: Testing SAP

Overview

This document contains a basic example for testing SAP-based applications.
The SAP connector requires a set of specific libraries which are listed in the SAP Connector requirements documentation. These libraries need to be added manually in order to test the SAP-based application correctly.

Find below the configuration needed to test a SAP connector using studio or using Maven respectively:

Configuration

From Studio

In your Studio environment:

  1. Add the SAP libraries to the classpath:

    1. Navigate to Build Path > Configure Build Path

    2. In the Libraries tab, click the Add Library …​ button

    3. Select Anypoint Connectors Dependencies

    4. Select the SAP Connector option.

      This process is also described in the SAP Connector documentation.

  2. You may also need to make the java.library.path point to the folder where the native libraries are located.
    The MUnit Studio plugin will try to find these native libraries and configure them automatically when you try to run your tests. In case they are not found, you need to add the following vm argument in the run configuration:

    1. In Studio top navigation bar, click run

    2. Click Run Configurations…​

    3. Select the Arguments tab

    4. In the VM Arguments dialog box, type the path to your libraries with the java.library.path argument.
      Example: -Djava.library.path=path/to/lib

      Vm Arguments

From Maven

One way of adding the libraries to the classpath is using the additionalClasspathElements parameter in the maven plugin.
You can provide the path to each of the SAP libraries that you want to add:

<additionalClasspathElements>
  <additionalClasspathElement>/path/to/lib/sapjco3.jar</additionalClasspathElement>
  <additionalClasspathElement>/path/to/lib/sapidoc3.jar</additionalClasspathElement>
</additionalClasspathElements>

If there is already a sap dependency in the pom, but the library name doesn’t match SAP naming restrictions, you may need to exclude them from the test run.
This way the libraries added with the additionalClassPathElement parameter will take precedence:

<classpathDependencyExcludes>
  <classpathDependencyExclude>com.sap.conn.idoc:sapidoc3</classpathDependencyExclude>
  <classpathDependencyExclude>com.sap.conn.jco:sapjco3</classpathDependencyExclude>
</classpathDependencyExcludes>

Additionally, you need to make the java.library.path property point to the native libraries directory, similar to how it’s done in Studio.
To accomplish this, you can use the argLine parameter to add the additional vm argument.

<argLines>
     <argLine>-Djava.library.path=/path/to/native/lib/folder</argLine>
</argLines>
The mentioned Maven Plugin configuration parameters are available since MUnit 1.3.5