question

nitinrastogi avatar image
nitinrastogi asked nitinrastogi posted

Help with response map

hi..

 

i want to create a response map for the following response:-

 

-rw-rw-rw-   1 xyz   wis        13151 Nov  9 04:30 abc.gen
-rw-rw-rw-   1 xyz  wis         4521 Nov  9 04:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:15 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:30 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:15 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:30 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 07:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 07:15 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 07:30 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 07:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 08:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 08:15 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 08:30 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 08:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 09:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 09:15 abc.gen

 

through response map i want to check the file size.If the file size comes greater than 31 then the test should pass else it should get failed.

Can someone please help me with this. I tried it but i dont know how to create a response map. 

iTestresponse map
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

PaulD avatar image
PaulD answered PaulD posted

This is a good opportunity to provide a little education on response mapping.  If you're new to response mapping, how should you think about getting started with mapping this?  The Fanfare customer support guys can probably give you a map quickly on this (as I could), but, as they say, sometimes it's better to teach people how to fish, rather than just feed them!

 

Anyway, here's how I think about mapping this thing you provided.  I've copied a few lines of it here into a code block, so that we can see how the columns line up (in fixed spacing font):

 

 

-rw-rw-rw-   1 xyz   wis        13151 Nov  9 04:30 abc.gen
-rw-rw-rw-   1 xyz   wis         4521 Nov  9 04:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:15 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:30 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 05:45 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:00 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:15 abc.gen
-rw-rw-rw-   1 xyz   wis           31 Nov  9 06:30 abc.gen

 

 

Step 1:  What kind of mapper should you use?

 

When possible, you generally want to use the table mapper if possible.  And this case is perfect for the table mapper.  (In fact, iTest's automatic mapper will map this quite nicely.)  The table mapper is appropriate if you have a repeating sequence with exactly one line per segment.  And that is the case here.  If the table mapper is not appropriate, then you usually want to use the pattern mapper, where you identify little blocks that are inside the response somewhere that you want to extract and parse.  You'll use the block mapper when you need to parse every field in the entire response AND when you have a repeating block structure where a certain field in each block is a key field for identifying that block.

 

Step 2:  For table mapper, how to identify columns?

 

When possible, you'd prefer to use a column delimiter to separate columns.  A column delimiter is often whitespace, but may be other things -- like comma-delimited text, or colons or semi-colons, etc.  iTest lets you choose the delimiter.  (A lot of people incorrectly think it only works with whitespace.)  There are some cases where you can't use a delimiter -- and that's when there is no single delimiter that separates all columns from one another.

 

This example is actually interesting because whitespace delimiters are okay as long as you don't mind getting each of those blocks in a single column.  But if you want to aggregate the date columns into a single column.  Or you want to break up the permissions (-rw-rw-rw) into separate columns, then you can't use a delimiter.  In that case, you need to have a response that follows strict column positioning -- and that is the case here.  (That's part of the reason that I showed this in a code block, so you can see that column positioning works nicely.)

 

So in this case, I might be inclined to use column positioning to identify columns.  In the response mapping, you just set the width of each column.

 

Step 3:  Choose a key column

 

In tables, it is very common for there to be a key column -- i.e., a column containing unique values such that you usually want to extract information from other cells in a row based on the value in that key column.  This example looks a lot like a directory listing -- yet the filename shown is always "abc.gen".  (I wonder whether you substituted this to hide some information?  Is it really repeating like this?)  If that column contained unique values like filenames, then you probably would want to make it into a key column.  And then you can create queries that look like "Size_By_Filename(<filename>)" which are very convenient.  

 

But if I believe the example you gave, I don't see a clear key column, so we won't have one.  In that case, you can just extract data using column name and row number.

 

You'll find that iTest can help you through a lot of this process.  When creating a response map, the Response view has a special "wizard" mode that will walk you through these steps -- giving you options along the way.

10 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

nitinrastogi avatar image nitinrastogi commented ·

Hi Paul,

 

Thanks for providing the detailed steps for creating the response map. I have tried as mentioned in the steps, but still i am facing the below problems.

 

   Column 5 of the response is the file size and i need to pass/fail my test case based upon its value.As you said i have created a table response map.

                         Query : col5(rowNumber)

                         XPath: (mapped/Tabular/table1/table/row)[{0}]/col5

 

now i am confused as to how to use it in the analysis rule to pass/fail my test case. As per my understanding what i understand from your reply is that  i should use column & row number to analyse it (correct me if i am wrong). But how to make it generic, not only for some particular row as the file size greater than 31 can come in any row.

 

Please help me in this. Thanks!!

 

0 Likes 0 ·
AdamB avatar image AdamB nitinrastogi commented ·

The assertion processor can do exactly that.

 

If you create a query for the xpath

 

 (mapped/Tabular/table1/table/row)/col5

 

 

it will return all values in "col5".  Now create an analysis rule that uses this query and asserts that the value is less than or equal to 31.

 

By default, it will analyze each value separately, generating an "error" for every row where the value is greater than 31.

 

 

0 Likes 0 ·
nitinrastogi avatar image nitinrastogi AdamB commented ·

Hello Adam,

 

Thank you so much for your reply. This solved my problem.

 

By the way, just out of curiosity  i want to know how to make a block map. Could you please explain me that with any sample response or may be you can use my sample response that i have posted earlier.That would be of great help :smileyhappy:

0 Likes 0 ·
KumarS avatar image KumarS nitinrastogi commented ·

You may want to search the forum on this topic. Here is one that might help you get started:

 

http://forums.fanfaresoftware.com/t5/Response-Mapping/How-to-get-started-with-block-mapping/m-p/281/highlight/true#M46

 

 

0 Likes 0 ·
nitinrastogi avatar image nitinrastogi KumarS commented ·

Hi Kumar,

 

Thanks for the link. i will surely try it out. :smileyhappy:

0 Likes 0 ·
YujieL avatar image YujieL nitinrastogi commented ·

Attached is an example of block map using the response you posted earlier.

 

This map contains just one block that can appear one or multiple times.

I've made the file size, month, day and time named tokens so you can later query the value of a particular token.

 

 

0 Likes 0 ·
map.ffrm (4.4 KiB)
AdamB avatar image AdamB YujieL commented ·

It's important to know where different mapping technologies are useful.  For this response Pattern and Table mapping are ideal because it is really just a single list and these mapping technologies deal with that better and are less brittle.  Block mapping really excels when there are multiple blocks of text in your response that have similarities and you want to extra much of that information. 

 

A good example for a block map would be a show interfaces command, or ifconfig.  As you can see in the following response example, there are a series of blocks for each network interface. Block mapping is great at allowing you to extract the IPv4 address for a given interface.  As you would create a block for each "interface" and then sub-blocks for the parts of that interface.

 

Windows IP Configuration

   Host Name . . . . . . . . . . . . : karma
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : fnfr.com

Wireless LAN adapter Wireless Network Connection 2:

   Connection-specific DNS Suffix  . : fnfr.com
   Description . . . . . . . . . . . : Intel(R) PRO/Wireless 3945ABG Network Connection #2
   Physical Address. . . . . . . . . : 00-1C-BF-4B-04-AD
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::cd34:fb47:a214:1cf4%19(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.155.0.131(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.254.0
   Lease Obtained. . . . . . . . . . : Wednesday, May 26, 2010 9:31:02 AM
   Lease Expires . . . . . . . . . . : Tuesday, June 01, 2010 9:31:03 AM
   Default Gateway . . . . . . . . . : 10.155.0.1
   DHCP Server . . . . . . . . . . . : 10.155.0.10
   DHCPv6 IAID . . . . . . . . . . . : 687873215
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-13-1E-62-26-00-18-8B-A8-2A-2C

   DNS Servers . . . . . . . . . . . : 10.155.0.10
                                       10.155.0.14
   Primary WINS Server . . . . . . . : 10.155.0.10
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Local Area Connection 3:

   Connection-specific DNS Suffix  . : fnfr.com
   Description . . . . . . . . . . . : Broadcom NetXtreme 57xx Gigabit Controller #2
   Physical Address. . . . . . . . . : 00-1C-23-1F-DA-63
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::c9a7:b1ba:875d:ad3c%17(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.155.0.178(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.254.0
   Lease Obtained. . . . . . . . . . : Wednesday, May 26, 2010 9:30:54 AM
   Lease Expires . . . . . . . . . . : Tuesday, June 01, 2010 9:30:55 AM
   Default Gateway . . . . . . . . . : 10.155.0.1
   DHCP Server . . . . . . . . . . . : 10.155.0.10
   DHCPv6 IAID . . . . . . . . . . . : 603986979
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-13-1E-62-26-00-18-8B-A8-2A-2C

   DNS Servers . . . . . . . . . . . : 10.155.0.10
                                       10.155.0.14
   Primary WINS Server . . . . . . . : 10.155.0.10
   NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter isatap.{65503C31-F68C-4BD9-A0CE-691C549DC80E}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #7
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

 

 

0 Likes 0 ·
nitinrastogi avatar image nitinrastogi YujieL commented ·

Hi Yujie,

 

While trying opening this response map i am getting the following error:-

 

"Deserialization error. Unknown element: sampleDictionary"

 

Please tell me how to corrctly open it?

 

Thanks..

0 Likes 0 ·
YujieL avatar image YujieL nitinrastogi commented ·

I might have used iTest 4.0 to generate the response. Are you using 3.4? I can provide another example using 3.4. 

0 Likes 0 ·
YujieL avatar image YujieL YujieL commented ·

Here is the same block map generated using iTest 3.4.

0 Likes 0 ·
map.ffrm (4.5 KiB)
Manish_soni avatar image
Manish_soni answered Manish_soni posted

Hello,

 

Could you please send your output with heading in a notepad   to us.(techsupport@fanfaresoftware.com ). Will send you the response map for this.

 

 

Thanks,

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.