Forum Discussion

cbyndr's avatar
cbyndr
Contributor
15 years ago

[SOLVED]is AMF response content available through MessageExchange?

I'm trying to create assertions to verify a certain AMF request response's content.

Some elements in this particular method's response may not always be verified without some string manipulation, so (I suppose) standard XQuery assertions won't always work.

I am thinking to use script assertion, and would like to know if I can get at the AMF reponse via MessageExchange. So, if this is the AMF response:


 
 
   
      0.75
      24
   

    32
    13
    usedQuotaBytes
    0.0
    preferences
   
     
     
       
          0.75
          12
       

        16
        1
        emailNotifications
        true
     

     
       
          false
          false
       

     

   

    3206715.0
    customerId
    machines
   
     
   

    contactRowId
   
    allocatedQuota
    0.0
    firstname
    quota
    150.0
    licenses
   
     
   

    messages
   
     
   

 

 
   
      false
      false
   

 



Could I capture the value of 150.0 in a script assertion by either of the following ways?

def groovyUtils = new com.eviware.soapui.support.GroovyUtilsPro( context )
def holder = groovyUtils.getXmlHolder( messageExchange.responseAsXML )
def quota = find_user_holder.getNodeValue("//flex.messaging.io.amf.ASObject[1]/map[1]/double[4]/text()")

Or

def groovyUtils = new com.eviware.soapui.support.GroovyUtilsPro( context )
def holder = groovyUtils.getXmlHolder( messageExchange.responseContent )
def quota = find_user_holder.getNodeValue("//flex.messaging.io.amf.ASObject[1]/map[1]/double[4]/text()")

7 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    please try the

    messageExchange.response.responseContentXML

    property. Does that work ok?

    regards!

    /Ole
    eviware.com
  • Hey, thanks for the response.

    Haven't gotten this to work yet. Here is what I have in my script:

    def holder;
    def quota;

    def groovyUtils = new com.eviware.soapui.support.GroovyUtilsPro( context );
    holder = groovyUtils.getXmlHolder( messageExchange.response.responseContentXML );
    quota = holder.getNodeValue("//flex.messaging.io.amf.ASObject[1]/map[1]/double[4]/text()");

    Which results in output of 'null'

    Fri Mar 05 06:50:28 EST 2010:INFO:null
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    i have tried your example and it works .
    But messageExchange is null object if you run script manually and it is not null while perform test step or test case. maybe you should do it like this :

    def groovyUtils = new com.eviware.soapui.support.GroovyUtilsPro( context );
    holder = groovyUtils.getXmlHolder( context.expand( '${AMF Request#ResponseAsXML}' ) );
    quota = holder.getNodeValue("//flex.messaging.io.amf.ASObject[1]/map[1]/double[4]/text()");
    assert quota == '150.0'


    or even shorter


    quota = context.expand( '${AMF Request#ResponseAsXML#//flex.messaging.io.amf.ASObject[1]/map[1]/double[4]/text()}' )
    assert quota == '150.0'


    hope this helps

    regards
    nebojsa
    eviware.com
  • Oh! One more thing.

    Is it possible to get at a properties step from a script assertion within an amf test step, the same you would from any other script assertion?

    Like this, for example:

    def testCase = messageExchange.modelItem.testStep.testCase
    def props = testCase.getTestStepByName( "properties" )
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,


    it is possible of course , but with minor change


    def testCase = messageExchange.modelItem.testCase
    def props = testCase.getTestStepByName( "properties" )


    In upcoming nightly build we will add changes so you can run your script as well.

    def testCase = messageExchange.modelItem.testStep.testCase
    def props = testCase.getTestStepByName( "properties" )


    regards
    Nebojsa
    eviware.com