Thursday, August 16, 2007

JMeter and DWR

I just follow this article to test DWR request in JMeter.
To tell the truth, I didn't get its content very well. I had no choice but read a second time and went through all comments.
So I decided to give a try in my desktop. Eventually I worked it out and now I can test DWR request.

Two important and great thing the author dig out is how to get httpSessionId and scriptSessionId for a DWR request.
Request for engine.js and use Regular Expression Extractor to get the scriptSessionId.
But this regular expression is for DWR2.0. Follow the link at the last to see a regular expression for latest DWR.
    dwr.engine._origScriptSessionId  = "(.*)";
double quotes work instead of single quotes for me.

For the httpSessionId, I got it from the Http Cookie Manager in the thread group, with the expression ${JSESSIONID}

One thing I forgot is DWR request method is 'POST', but not 'GET' which is the default value when adding a new Http Request.

Tuesday, August 14, 2007

Performance Testing?

We are going to use JMeter to take the performance testing in our project.
Till now I have no idea about how to contribute it to the project.
I read several documentations at the official site, just finding I lost at the graph results and some concepts.
Also I failed to use the Assertion component to validate the response.
Have to continue researching.

These two days I back to write functional test using Selenium.
In the previous practice, I enjoyed locating elements by XPath. I found it's definitely easy for almost all elements.
Even though people say different browsers may evaluate the expressions differently. I just ignored this problem now because we only need to focus on Mozilla's Firefox. But this time I encountered a situation (siniarie?) that a page has a tree hierarchy which is created by YUI treeview component.
So I tried to use DOM locater. It's not very difficult to write the Javascript expressions.
And problem is about the frame element. The Javascripts didn't work in the main page which contained a frame element.
But it did work well in the page itself which that frame referred.
There's a Selenium function named selectFrame. It seemed it either did not work out.
Or I used it in a wrong way?

Two's component

Two's component is one of the Signed number representations. Its principles is described as following. (refer to original at http://en.wikipedia.org/wiki/Two%27s_complement )

The 2n possible values of n bits actually form a ring of equivalence classes, namely the integers modulo 2n, Z/(2n)Z . Each class represents a set {j + k 2n | k is an integer} for some integer j, 0 ≤ j ≤ 2 n − 1. There are 2n such sets, and addition and multiplication are well-defined on them.

If the classes are taken to represent the numbers 0 to 2n − 1, and overflow ignored, then these are the unsigned integers. But each of these numbers is equivalent to itself minus 2 n. So the classes could be understood to represent −2n−1 to 2n−1 − 1, by subtracting 2n from half of them (specifically [2n−1, 2 n−1]).

For example, with eight bits, the unsigned bytes are 0 to 255. Subtracting 256 from the top half (128 to 255) yields the signed bytes −128 to 127.

The relationship to two's complement is realized by noting that 256 = 255 + 1, and (255 − x) is the ones' complement of x.

Example

−95 modulo 256 is equivalent to 161 since

−95 + 256
= −95 + 255 + 1
= 255 − 95 + 1
= 160 + 1
= 161
And I have to say I can't understand the content well. The mathmatics concept is somehow complex to me. Why I got the idea to find out what's two's component is just because the Java puzzler below.

public class JoyOfHex { public static void main(String[] args) { System.out.println( Long.toHexString(0x100000000L + 0xcafebabe)); } }

What's the result? Obviously it should print 1cafebabe. Right? Wrong.During the computation, is promoted to the long value 0xffffffffcafebabeL.(I got missed here. Why?)So the result is: 0x00000000cafebabeL. Fix this problem as simple as using a long hex literal to represent the right operand.
Long.toHexString(0x100000000L + 0xcafebabe L));

Reference:
Java™ Puzzlers: Traps, Pitfalls, and Corner Cases By Joshua Bloch, Neal Gafter
www.wikipedia.org