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
- FININQ2.cbl - COBOL program.
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.
- 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
- Define the project name and the default package
- Select Mainframe CICS TG as the backend and click Next
- 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. - Click Finish
- Open src/main/resources/application.yml file and add the value
IPCSSL
in todefault-ipic-server
property like the following:
Illustrative example:
Testing the Configuration
- Make sure your environment has no errors.
- Do a Maven update if needed.
- 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.
- Right-click on src/main/resources → New → Folder to create a new folder. The folder name should be 'sample'
- Copy FININQ2.cbl to
src/main/resources/sample
folder. - Right-click on the file → OpenLegacy → Generate Model
- In the 'Execute Path' field, write FININQ2
- Check Generate JUnit Test checkbox.
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...
- Open the generated mock at `src/test/resources/mock/test_fininq2Test_usecase_1.input.json`
Define the `custId` as `412-83254`.
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:- Copy the response to `src/test/resources/mock/Fininq2Test/test_fininq2Test_usecase_1.output.json`.
- 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.