How do you specify the XSL when testing with XSLTScenario? - Forum - Technology Partner - Progress Community

How do you specify the XSL when testing with XSLTScenario?

 Forum

How do you specify the XSL when testing with XSLTScenario?

  • When developing an XSLT test case using the Sonic JUnit Framework, how do you specify the stylesheet URL you want to test in XSLTScenario?

    The Help files and Javadocs in Sonic Workbench are of no help when it comes to using XSLTScenario. I've tried implementing getArtifactURL() by returning the sonicfs:// URL to my stylesheet. I've also tried implementing getAdvancedProperties() by returning a Map with a key-value pair of XFORM_STYLESHEET_URL and the sonicfs:// URL to my stylesheet. Neither has any effect; the ESB JUnit framework simply ignores me and uses whatever is specified for dev.Transform's Default Stylesheet URL (sonicfs:///System/SonicESB/copy.xslt).

    If however I change dev.Transform's Default Stylesheet URL to that of my stylesheet, and run my JUnit test case, it uses my stylesheet. Obviously that is not workable from the perspective of automated tests.

    Thanks.

  • You can set the style sheet against the Request object. Look at the line of code marked // <my stylesheet here

    private MsgRequest createRequest(String inputURL) {

    MsgRequest msgRequest = RequestFactory.createMsgRequest();

    XQMessage message = null;

    try {

    message = msgRequest.createXQMessage(inputURL);

    } catch (Exception e) {

    result.addError(this,e);

    }

    msgRequest.setXQMessage(message);

    Properties p = new Properties();

    p.put(XSLTScenario.XFORM_STYLESHEET_URL,

    "sonicfs:///workspace/Demo/files/test.xsl"); // <my stylesheet here

    msgRequest.setEnvironmentParams(p);

    return msgRequest;

    }

    The scenario takes in the inputs. To keep the invocation style uniform, the stylesheet is wrapped in a process dynamically and the request provides all the details (the same as the Service Runtime parameters). I agree that this isn't all that intuitive.

    Hope this helps.

  • Success!

    Thank you Sachin. Calling MsgRequest.setEnvironmentParams(Properties) as you described worked. The ESB JUnit framework now recognizes and uses my XSL stylesheet.

    Thank you to Progress Software and the Progress Software Developers Network for making these forums available. They are a tremendous help.

    Note to Progress: Please update the Workbench Help documentation and the ESB JUnit API Javadocs in the next release by adding clear explanations of how to use the classes and methods for testing with the various Scenarios. Us disciples of Test-Driven Development rely heavily on these artifacts.