Mainframe CICS TG - SDK Exercise

Mainframe CICS TG - SDK Exercise

Introduction

This exercise will develop your skills with OpenLegacy IDE by generating Java models from existing sources and creating unit tests to validate backend connectivity and data.

Pre-Requirements

  • OpenLegacy IDE 4.5.2 (Full installation including JDK and all Maven dependencies).
  • Internet Connection

Exercise Resources

Exercise Definition

  • Create a new SDK Project.
  • Generate Java model (Entity) from COBOL source file.
  • Develop unit tests on the fly.
  • Test the connectivity and data retrieval from the Mainframe host.

Step 1 – Create a New SDK Project

First, we will create a new SDK project using OpenLegacy IDE.
The purpose of the SDK project is to allow easy access to legacy backends, using standard and easy to use Java code.

Project Setup

Create a new OpenLegacy CICS TG RPC project.

  1. Open the New Project Wizard (you have three options):
    • File → New → OpenLegacy SDK Project
    • Alt+Shift+N → OpenLegacy SDK Project
    • File → New → Project → Select OpenLegacy SDK Project from the drop-down
  2. Define the project name and the default package
  3. Select Mainframe CICS TG as the backend and click Next
  4. Enter the following CICS TG host credentials:
    • Host Name/IP: 192.86.32.142 
    • Host Port: 13200
    • Code Page: CP037

    These credentials can be edited easily in the properties file located at src/main/resources/application.yml file.

  5. Click Finish
  6. Open src/main/resources/application.yml file and add the value IPCSSL in to default-ipic-server property like the following:

Illustrative example:


Testing the Configuration

  1. Make sure your environment has no errors.
  2. Do a Maven update if needed.
  3. Do a project -> clean if needed (not Maven clean).

Congratulations! You are ready to start working on the API.

Step 2 – Generate Java Model (Entity) From COBOL File

Let's create Java models out of our demo COBOL file.

  1. Right-click on src/main/resources → New → Folder to create a new folder. The folder name should be 'sample'
  2. Copy FININQ2.cbl to src/main/resources/sample folder.
  3. Right-click on the file → OpenLegacy → Generate Model
  4. In the 'Execute Path' field, write FININQ2
  5. Check Generate JUnit Test checkbox.
  6. Click OK


The transaction Id is an optional field that allows you to invoke a program through existing transactions, like your custom logger.

Illustrative example:


Step 3 – Create a JUnit Test

OpenLegacy enables test-driven development by auto-generating test suites for each backend program(Entities).
We can extend this test suite with additional unit tests to validate our connectivity to the backend, validate the requests/responses etc...

  1. Open the generated mock at `src/test/resources/mock/test_fininq2Test_usecase_1.input.json`
  2. Define the `custId` as `412-83254`.

  3. Open the generated JUnit test at `src/test/java/tests/Fininq2Test.java`, mark the second test as comment and run the JUnit by Right Clicking on `Fininq2` → Run As → JUnit Tests.
    If you followed all the steps correctly you should receive the following response returned directly from the Mainframe:

  4. Copy the response to `src/test/resources/mock/Fininq2Test/test_fininq2Test_usecase_1.output.json`.
  5. Run the JUnit test again.

Press Ctrl+Shift+O to automatically organize the imports and add missing classes

Conclusion

You learned how to create a Java entity from a Mainframe CICS TG COBOL Program.


Related content