AnsweredAssumed Answered

Subject: Looking for any example/trick of a *test step* that produces (process response) a "flat message" based on a XML message and a Copybook Data Protocol handler

Question asked by Didier_Burkhalter Employee on Dec 5, 2014
Latest reply on Dec 11, 2014 by Josh_Hendrick

Subject: Looking for any example/trick of a *test step* that produces (process response) a "flat message" based on a XML message and a Copybook Data Protocol handler

 

(not sure that the question has been correctly posted previously)

 

I am looking for your expertise on cobol copy book and test side ;

 

Context: building regression tests against cobol MF application under migration (SUT); regressions will run against either Java entry point or a Web service hosted in JavaEE front end


Requirements:

1/ I have an XML « representation » of an ASCII "Copybook «  message " that I like to variabilize

Say:

 

<?xml version="1.0" encoding="UTF-8"?>

 

<copybook-payload>

  <rawHeader>30303137373030303433303031393930202020202020202020202020202020202020343330302020202020</rawHeader>

  <Body>

    <CQSDAT>

      <S000-RECUPDAT>

        <S000-C1ENTSRV>

          <S000-ESRV-LGSERV left-pad-length="0" origin-length="5 »>{{MY-VARIABLE}}</S000-ESRV-LGSERV>

          <S000-ESRV-PISRVC left-pad-length="0" origin-length="12">CQSDAT</S000-ESRV-PISRVC>


2/ I had like then  to transform (marshall)  this XML message to its « flat » format using either a "Java Create Response » (with com.itko.lisa.vse.stateful.model.Response class) or a Java script test and a Copybook Data Protocol handler

, to mimic the behavior of a Virtual HTTPS Responder that does the job (create Response, process response, apply copybook mapping handler, then base 64 encode in a next play back handler)

 

All these operations are test steps and hosted in a regression test

Sor far , the message is not marshal to its « raw » text format but remains in following XML format

 

"Response [1340942475] {id=0, metaData=RESPONSE_PAYLOAD_DEF_NAME_KEY=CQSDAT&ORIGINAL_ENCODING=ASCII&WAS_BINARY_RESPONSE_KEY=false, binary=false, body=(non-binary)<?xml version=""1.0"" encoding=""UTF-8""?>

 

<copybook-payload>

  <rawHeader>3030313737...202020</rawHeader>

  <Body>

    <CQSDAT>

      <S000-RECUPDAT>

        <S000-C1ENTSRV>

          <S000-ESRV-LGSERV left-pad-length=""0"" origin-length=""5"">00134</S000-ESRV-LGSERV>

          <S000-ESRV-PISRVC left-pad-length=""0"" origin-length=""12"">CQSDAT</S000-ESRV-PISRVC>

...

...

questions:

  • is it possible to do what I am looking for and what is the trick if any  (I have heard of transient response being involved with the response object ?
  • If yes, can you share either trick of test example ?
  • … Or any advice

To workaround this behavior, I have a VS that does the job with classic SV features but can be perceived as an over complicated pattern

 

Tia,

Didier

Here is my test script :

 

import com.itko.util.ParameterList;

 

import com.itko.util.Parameter;

import com.itko.util.Base64;

import com.itko.lisa.vse.stateful.model.Response;

import com.itko.lisa.vse.stateful.model.TransientResponse;


String anXMLbody = testExec.getStateValue("CQSDAT_xml");


aResponse = new com.itko.lisa.vse.stateful.model.Response();


aTransientResponse = new com.itko.lisa.vse.stateful.model.TransientResponse(aResponse);

aResponse.setBodyText(anXMLbody);

aTransientResponse.setBodyText(anXMLbody);


//aResponse.setCharset( "ASCII" );

//aResponse.setBinary( false );


// Metadata is a ParameterList

ParameterList metadata = aResponse.getMetaData();


metadata.addParameter(new Parameter("RESPONSE_PAYLOAD_DEF_NAME_KEY", "RESPONSE_PAYLOAD_DEF_NAME_KEY", "CQSDAT"));

metadata.addParameter(new Parameter("ORIGINAL_ENCODING", "ORIGINAL_ENCODING", "ASCII"));

metadata.addParameter(new Parameter("WAS_BINARY_RESPONSE_KEY", "WAS_BINARY_RESPONSE_KEY", "false"));


aResponse.setMetaData(metadata);

aTransientResponse.setMetaData(metadata);


return aResponse;


And the cobol DPH:

cobol_dph.png

 

Outcomes