Service Virtualization

  • 1.  How to nullify ^M character on Unix environment?

    Posted Sep 28, 2017 02:19 PM

    Greetings Team,

     

    I have encountered a situation, created a JMS based VS to mimic a Service which is hosted on Windows platform. The Response of the VS needs to be sent to WebLogic which is running on Unix platform.

     

    When the message is received on Unix platform "^M" character is appended at the end of each line and hence an error message is thrown.

     

    Please let me know, is there any way by adding certain control characters we can nullify ^M on unix platform?

     

    Quick response would be highly appreciated.

     

    Thanks in advance.



  • 2.  Re: How to nullify ^M character on Unix environment?

    Posted Sep 28, 2017 03:59 PM

    That '^M' you see is some UNIX applications' representation of the Carriage Return character (0x0D).  UNIX newlines are just Line Feed (0x0A), while DOS/Windows newlines are Carriage Return + Line Feed (0x0D 0x0A).  If you see an '^M' at the end of each line on UNIX then that means the text is using Windows newlines.

     

    I'm pretty sure that VSE sends whatever newline characters are there in the response data.  However, that may depend on exactly how the service image was generated and what data protocols you have.  If you are generating your service image from request/response pairs then make sure your response files are using UNIX newlines. 

     

    If all else fails then you can add a response-side scripted data protocol to translate newlines from DOS to UNIX format:

     

    lisa_vse_request.setBodyText(lisa_vse_request.getBodyText().replaceAll("\r\n", "\n");



  • 3.  Re: How to nullify ^M character on Unix environment?

    Posted Sep 28, 2017 04:09 PM

    Thanks for the quick response Kevin.

     

    Should I be adding the above script in both the Response-Recording and Response-Playback tabs of Scriptable DPH?

     

    Thanks in advance.



  • 4.  Re: How to nullify ^M character on Unix environment?

    Posted Sep 28, 2017 05:07 PM

    I added the provided script in both the tabs of response side scriptable DPH, below error message was received.

     

    Note:- I have already added a Scriptable DPH on the response side to replace unprintable characters with something printable

     

     In 'Response - Record', :

     

    %beanshell%
    String text = lisa_vse_response.getBodyText();
    text = text.replaceAll("\\u0001", "(0x01)/");
    text = text.replaceAll("\\u0002", "(0x02)/");
    text = text.replaceAll("\\u0003", "(0x03)/");
    lisa_vse_response.setBodyText(text);

     

     

    In the 'Response - Playback' tab, 

     

    %beanshell%
    String text = lisa_vse_response.getBodyText();
    text = text.replaceAll("(0x01)/", "\\u0001");
    text = text.replaceAll("(0x02)/", "\\u0002");
    text = text.replaceAll("(0x03)/", "\\u0003");
    lisa_vse_response.setBodyText(text);

     

    DevTest Server Console

    Did not get a valid response object so we ignore processing this transaction.  com.thoughtworks.xstream.io.StreamException:  : only whitespace content allowed before start tag and not ( (position: START_DOCUMENT seen \r\n(... @2:2)       at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103)      at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63)      at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:54)      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)      at com.itko.lisa.vse.stateful.model.Streamer.fromXML(Streamer.java:92)      at com.itko.lisa.vse.stateful.common.DataProtocolStandardControlFilter.subPreFilter(DataProtocolStandardControlFilter.java:164)      at com.itko.lisa.test.FilterBaseImpl.subFilter(FilterBaseImpl.java:148)      at com.itko.lisa.test.FilterBaseImpl.preFilter(FilterBaseImpl.java:95)      at com.itko.lisa.test.TestNode.doFilters(TestNode.java:1464)      at com.itko.lisa.test.TestNode.doPreFilters(TestNode.java:1417)      at com.itko.lisa.test.TestNode.executeNode(TestNode.java:964)      at com.itko.lisa.test.TestCase.execute(TestCase.java:1283)      at com.itko.lisa.test.TestCase.execute(TestCase.java:1198)      at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1183)      at com.itko.lisa.test.TestCase.executeTest(TestCase.java:1127)      at com.itko.lisa.coordinator.Instance.run(Instance.java:204) Caused by: org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not ( (position: START_DOCUMENT seen \r\n(... @2:2)       at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1519)      at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)      at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)      at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109)      ... 20 more


  • 5.  Re: How to nullify ^M character on Unix environment?

    Posted Oct 02, 2017 01:09 PM

    I added the provided script in both the tabs of response side scriptable DPH, below error message was received.

     

    Note:- I have already added a Scriptable DPH on the response side to replace unprintable characters with something printable

     

     In 'Response - Record', :

     

    %beanshell%
    String text = lisa_vse_response.getBodyText();
    text = text.replaceAll("\\u0001", "(0x01)/");
    text = text.replaceAll("\\u0002", "(0x02)/");
    text = text.replaceAll("\\u0003", "(0x03)/");
    lisa_vse_response.setBodyText(text);

     

     

    In the 'Response - Playback' tab, 

     

    %beanshell%
    String text = lisa_vse_response.getBodyText();
    text = text.replaceAll("(0x01)/", "\\u0001");
    text = text.replaceAll("(0x02)/", "\\u0002");
    text = text.replaceAll("(0x03)/", "\\u0003");
    lisa_vse_response.setBodyText(text);

     

    DevTest Server Console

    Did not get a valid response object so we ignore processing this transaction.  com.thoughtworks.xstream.io.StreamException:  : only whitespace content allowed before start tag and not ( (position: START_DOCUMENT seen \r\n(... @2:2)       at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118)      at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103)      at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63)      at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:54)      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)      at com.itko.lisa.vse.stateful.model.Streamer.fromXML(Streamer.java:92)      at com.itko.lisa.vse.stateful.common.DataProtocolStandardControlFilter.subPreFilter(DataProtocolStandardControlFilter.java:164)      at com.itko.lisa.test.FilterBaseImpl.subFilter(FilterBaseImpl.java:148)      at com.itko.lisa.test.FilterBaseImpl.preFilter(FilterBaseImpl.java:95)      at com.itko.lisa.test.TestNode.doFilters(TestNode.java:1464)      at com.itko.lisa.test.TestNode.doPreFilters(TestNode.java:1417)      at com.itko.lisa.test.TestNode.executeNode(TestNode.java:964)      at com.itko.lisa.test.TestCase.execute(TestCase.java:1283)      at com.itko.lisa.test.TestCase.execute(TestCase.java:1198)      at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1183)      at com.itko.lisa.test.TestCase.executeTest(TestCase.java:1127)      at com.itko.lisa.coordinator.Instance.run(Instance.java:204) Caused by: org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not ( (position: START_DOCUMENT seen \r\n(... @2:2)       at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1519)      at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)      at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)      at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109)      ... 20 more


  • 6.  Re: How to nullify ^M character on Unix environment?
    Best Answer

    Posted Oct 03, 2017 05:52 PM

    Maddy007 have you considered opening a support case? 

     

    You appear to be having a multitude of issues on at least three different forum threads.  They may or may not all be related, but I need more information than I can ask over a public forum.  Can we get a support case where we consolidate all these problems and look at them as a whole?



  • 7.  Re: How to nullify ^M character on Unix environment?

    Posted Oct 03, 2017 11:15 PM

    Greetings Kevin,

     

    Sure, will collect all the relevant details and open a support case for analysis.

     

    Thanks again:)