One of the biggest bottlenecks in IBM Sterling Order Management (OMS) development is the "Wait Time." Traditionally, testing custom Java code-whether it's a Property Provider, a Custom API, or a User Exit-requires a full rebuild and deployment to an Agent or Application Server.
IntelliJ IDEA can be used to simulate the Sterling runtime, you can execute and debug your code locally in seconds. Here is how to set up your environment
Pre-Requisites
Step 1: Configuring the Project Structure (Classpath)
We need to ensure IntelliJ recognizes the Sterling engine and your custom logic.
-
Open Project Structure (Ctrl+Alt+Shift+S) > Modules > Dependencies.
-
Add Sterling Jars: Add all necessary OOB and Custom Jars from your codebase.
-
Map Properties: Add your <INSTALL_DIR>/properties folder as a dependency.
-
Map Foundation: Add the <INSTALL_DIR> directory itself.
-
Prioritize Resources: > Crucial Step: Move resources.jar to the very top of the dependencies list. This ensures that the engine picks up the correct configuration files during initialization.
Step 2: Creating the Run/Debug Configuration
Instead of running an Ant script, we will create a standard Java Application configuration.
Step 3: JVM Bootstrapping (VM Options)
This is the "Secret Sauce" that tricks the code into believing it is running inside a Sterling container. Copy these into your VM Options field (replacing <INSTALL_DIR> with your path):
<response-element class="" ng-version="0.0.0-PLACEHOLDER"></response-element>
public class OMSTest2 {
public static void main(String[] args) {
try {
YIFApi api = createApi();
YFSEnvironment env = createEnvironmentObject(api);
// Once environment is created you now you can invoke API/Service
// Document docOut = api.invoke(env,"getCommonCodeList", docInput);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Document convertStringToDocument(String xmlString) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(xmlString));
Document document = builder.parse(inputSource);
document.getDocumentElement().normalize();
return document;
}
private static YIFApi createApi() throws YIFClientCreationException {
YIFApi yifapi = null;
yifapi = YIFClientFactory.getInstance().getApi();
return yifapi;
}
private static YFSEnvironment createEnvironmentObject(YIFApi api) throws Exception {
String envString = "<Environment userId=\"<userid>\" progId=\"<ProgId>\"/>";
return api.createEnvironment(convertStringToDocument(envString));
}
}
------------------------------
Sudheer Chadalavada
------------------------------