Tuesday, November 4, 2014

My Thailand Voyage


After lots of planning and preparation we made our bookings for Phuket and this was my tour experience:

Day 1:

Our flight arrived in Bangkok at 6:15 AM, and that is where our marathon for Visa On Arrival started. We didn't think it would be that hard to get the Visa on Arrival, the transit time was very less as we had to catch up with the connecting flight to Phuket, which would be flying at 8:45 AM. The Bankok airport was huge and we were cursing ourselves that why didn't we got the visa beforehand from the Embassy, but what happened has happened and our walking to Visa On Arrival counter was going on and on and on. I remember we walked for a 1 Kilometer from the Arrival gate. When we finally reached the counter, we see that there was a quite a bit of queue, and we had no other option to take the Express Lane queue which was empty, and we had to pay extra 200 Bahts for that and we did so. We took the Visa and again started to go for Transit counter which was another ~800 meters from the Visa On Arrival counter. When we reached there we went through the customary process of security checks and finally boarded the flight, and the flight was delayed by 10 minutes after we boarded, as few more passengers were yet to come, I thought it must be due to Visa queue. So whosoever consider a visa on arrival in Bangkok, must make sure that you have enough time for your next flight, otherwise consider applying for the visa from the Embassy from your home country. The flight journey was for 1 hour 15 minutes, we arrived in Phuket at 9:20 AM, collected our baggage and went to Car Rental counter which we have booked earlier through online, we were 6 people so we booked a SUV and the representative said it would take time, may be around ~3-4 hours, so in the meanwhile they allotted us another car to go to the hotel. I must say we really had a tough time in communicating with the people in Thailand, we had to speak clearly/slowly every word, without using any dictionary words. We took a new 3G activated SIM card and found our way to hotel - Palmery Resort & SPA in Kata (we used Apple Maps to know route and we ended up on top of the hill, we switched to Google Maps). We reached the hotel, checked-in to the rooms, the hotel was awesome, especially the pool view from the room balcony. We took rest for hour or so, had lunch in the nearby restaurant, and Veggies be cautions about what you order, the ingredients in the dishes you have to clearly mention that you don't need egg, no fish, no meat etc otherwise they would bring you a fried rice with egg in it or veg fried rice without egg and fish oil as sauce, so please be aware of it. After the lunch, we went on to find out the tour prices to Phi-Phi islands, Phang Nga bay etc. Found that in June - October period the prices will drop by 50-60%, in the peak periods December to February the tour agencies won't discount a single baht, lucky that we didn't book island tours online. As our tour was in September, the tour prices were between 1000-1400 bahts. After finding out the basic information on tour prices, we received our SUV from the car agency and went to visit Karon View Point which is by the way was spectacular, took few snaps, went to visit Big Buddha - massive statue of Buddha on top of hill and by the way we had a great view of Big Buddha from our hotel room. we took few snaps there and we left to Patong to have a look of Bangla Street (giggles), though the activity was not started by the time we reached there. We booked tour to Phi-Phi islands from "Phuket New Generation (PNT)" tour agency for 1300 Bahts in a Speed Boat which can carry up to 30 - 40 people. We googled for Indian restaurants in our vicinity, went there and ordered the dishes, and of course the cost was very high (twice, thrice the base price in India). We reached the hotel and took a nice nap.

Hotel Pool View:

 Hotel room:
 Karon View Point:
 Big Buddha:

Day 2: Phi - Phi Islands tour

We had to woke up in early at 6:30 AM to get ready, have breakfast and to board the tour agency car to reach the port area. we boarded the car at 7:45 AM and reached the port area by 9:00 AM, when we reached it was buzzed with lot of people. I took a coffee and the tour agency guy, Bobby, put stickers on our t-shirts. Bobby is fun, speaks good English and in good accent. We started our way to Phi-Phi islands by speed boat. I must say we had lot of fun with Bobby in our journey to islands. We visited Monkey Island, Khai Nui, Khai Nuk islands, I don't remember the island names correctly, but it was a visible treat, water was/is crystal clear, we could see the fishes and coral reeds. We did snorkeling in crystal clear water, I will remember those scenes for my entire life-time, I thoroughly enjoyed swimming with fins over there. We really had a nice time. We had lunch on island, veggies could not eat anything over there, even people who eat meat had tough time because the food was bland, no salt, not spicy etc. we ate what we could like noodles, steam rice etc. Took some snaps on island, did shopping and started for our final island visit, when we reached there the water was shallow enough to cause injuries, even in the shallow water we did snorkeling, I got few bruises to my wrist. I handed over my fins to my friend so that he could enjoy the swimming, he greatly relished the beauty of  fishes and reeds. Be careful when you are snorkeling in shallow water without the fins you might get hurt by the stings of Sea Urchins or by the rocks. We finished with swimming and started back to Phuket. We headed back to our hotel in the transport arranged by the tour agency, it was 6 PM when we reached hotel. We swam again in hotel pool for more than hour. We went out at 8 PM for dinner to Indian restaurant and the bill cost us dearly and after this dinner I stopped going to Indian restaurant. Few of my friends went to Bangla street to do some shopping, live bands etc. My friend dropped me at the hotel and I stayed back at the hotel that day.

Bobby:
 Lunch on Island:

 Fishes:
 Snorkeling:

 Monkey Island:





Day 3:

I woke up at 9:30 AM in the morning and had breakfast, I initially planned to visit the cabaret shows in Phuket but my friends objected that it is not worth it. I told them about Tiger Kingdom, Flying Hanuman places, we got ready by 12 PM and started to Tiger Kingdom, we paid 800 Baht per head to stay with Big Tiger, the price can go up if you wish to stay with younger tiger. I must say it was the bravest thing I have ever done. I was the first to enter into the cage my heart beat stopped for a tick the moment I entered, I thought it would be easy but it was scary in the initial moments, especially when I was asked to place my hand on magnificent creature's belly, but as we stayed in the cage with other staff I felt safer and took many snaps, our hands and forehead sweaty, I think this was the bravest thing that we did in our tour other than jumping in the sea without life jackets and zip lining at Flying Hanuman It was life time experience and of course worth every penny. After that we rushed to Flying Hanuman place as we were told that it would be closed by 3 or 4 in the evening. Few of friends told that they didn't want to do it, only two of us went on to do the zip-lining. It was bit costly but I just wanted to experience everything in Phuket, there were three options for choosing the zip-lining activity. Both of us opted for 'C' program which includes 12-16 zip lines. It was worth it, especially in the jungle, there are short, long zip lines. It was a nice experience. After this we waited for the rest of the friends who went back to have lunch, the came back at 5 and we started back to hotel to freshen-up. We started again at 7 PM, booked Big Boat Phang Nga tour for 900 Bahts, went to Bangla Street for live band music, we sat in New York bar for most of the time, the live band was very good, good song selection and nice crowd. We stayed there till 1 AM and came back to hotel by 1.30AM.



Day 4: Phang Nga tour

we woke up at 7:15 AM and by the time the driver had reached the hotel lobby, we were having our breakfast we asked him to wait for few minutes, he rejected and seemed to be in a rush. We had no choice to board the cab, we didn't finish our breakfast, so people who go on tour should be on-time. Few other tourists boarded the cab and it took 1 hour journey to Ao por pier. I think we were second to reach the tour agency shop, and we waited for another 30 mins for another group to arrive. After they've arrived, all of us started to board the Big Boat, we were around 30-40 people in the boat, the journey included 3 islands (not the Muslim village - we missed it, it is an unique village where all the houses are built on a floating platform - may be next time ;-)  ). We visited Hong Island, James bond Island, few naturally formed caves which included Bat cave and others. We did cannoning on few islands as the water suites for cannoning, no snorkeling on these waters just only swimming. It was evening when we reached James Bond Island (funny name isn't it. The island was named after the james bond movie - "Man with the Golden Gun") we were transferred to long tail boat to reach the island as the water was very shallow, we took lot of snaps over there, spent some time on the island and started over journey to Phuket, it took 1 hour 45 minutes to reach Ao Por pier, during the journey we passed our time by singing songs and by casual talk. We came back to hotel at 6 PM, freshen up, went out to find out about Water Rafting tour, we inquired about cost, the tour plan etc and made a good deal for 900 Bahts. We initially booked only for 3 people as 3 others wanted to explore the Phuket city, so we went on with our choices. Later one other joined us in total 4 people booked the tour. We spent the entire night in Bangla Street by spending most of the time in New York Bar by enjoying the Live Band. We came back to hotel at 2:30 AM and slept.

Cannoning:






Transfer to James Bond island by Long Tail boat:

 James Bond Island:



Day 5: Water rafting, Waterfalls, elephant trekking, zip lining.

We woke at 7:30 AM, we were ready by 8 AM, but the cab didn't arrive. We called to the tour agency and found out that driver went to the wrong hotel and he went on without picking us up. The tour agency sent another cab for us, finally by 9 AM the cab has arrived, we 4 boarded the cab and started our journey. We had a tough time in communicating with this driver, he always say "elepant treking...elepant treking..elepant treking....twanthy meenuts". We had no choice except to remain silent. After 1 hour 30 mins of journey we reached Monkey Cave, to our surprise they asked us to pay the entry fee, it was only a cave and my friends didn't want to go inside and so we started again from there to reach the elephant trekking spot, that was the first time I ever touched an elephant. For first few moments I was afraid to touch it or go near the trunk of the elephant, but I dared to stand beside it and took snap of it. After a while many other elephants returned from the trek. My friend and I sat on a the elephant, it was not an easy task to sit on a wobbling seat. The elephants knew the way completely, the were doing trekking without mahouts. It was wonderful trekking experience, the whole trek was in a forest, the land was not flat. We had to hold to the ropes of the chair. The total trek was about 20-30 minutes. We reached back to the place where the elephants were tethered, we boarded the cab again and reached a hotel for our lunch, this time they did pay special attention to the veggies, they asked about our preference and they made the dishes. Although the food was very bland (in thailand they don't use salt in their dishes), we had to put enough salt in the noodles for a good taste. We were taken to waterfalls after we finished our lunch. It was fresh-water waterfalls, lots of fishes, we swam for about 30mins or so, spoke to other tourists over there, and started our journey to most awaited activity of the day - Water Rafting. We reached the starting point of the rafting, other tourists joined us. We were given a single raft for 4 of us, 2 other people were trained people who operated the raft. This was our first experience of water rafting. In the middle of rafting I jumped out of the raft without life jacket for swimming, and I knew I was in trouble, the water current was good enough to push you out. I immediately requested for life jacket, my friends thew me a jacket I put on it, then I came back on the raft and we continued our rafting, there were few spots were we thoroughly enjoyed it. If you can't hold on the support ropes on the raft you will have tough time on raft, you have to pay attention on when we are going to have an impact. The water rafting was 5 KM, they charged extra 400 Bahts for 2 KMs but we didn't take it. We came back to the place where we had our lunch. We did 250 meter zip-lining here. I did it twice to get good video and snaps ;-) and then we started back to our hotel, we reached hotel at 6 PM. We waited for other friends to join us. We went out for shopping, we did shopping, bought some leather purses, electronic equipments etc. we stayed in Bangla Street till 2:30 AM, we reached back to the hotel at 3 AM and we slept.

Monkey Cave:
 Elephant trekking:

 Zip-lining:
 White water rating:


Day 6: Back to home - Karon Beach, tight timeline, shopping, shopping, drive back to airport

We woke up at 9:30 AM, one of my friends searched for a good massage center (only massage no other extra activities) we found out about "Sweet Lemongrass Massage" center, I had best massage in my life, they knew the correct pressure points, they are certified masseurs. They charged 350 Bahts for 60 mins of Traditional Thai Massage + Oil Massage. Everyone of us really loved it. The tripadvisor rating really fits them. Few of my friends even did massage for 90 mins. After the massage we came back to hotel, we jumped in the pool, that's when the hotel crew arrived and reminded us about our checkout time, we spent 15 minutes in the pool, came out of it, packed everything and then we checkout of the hotel and went to Bangla street to finish off the pending shopping list. We arrived there at 2 PM and agreed that everyone would finish off with their shopping by 3 PM and meet at a common point, my friend and I shopped leather bags, t-shirts, phone power banks etc and reached the common point, few of my friends were still shopping or in the middle of lunch. Finally by 4:10 PM we gathered and started to airport which was 40 mins drive from Bangla street. We reached airport at 5 or 5:10 PM, we handed over the car to the car rental agency, and we checked-in our baggage. The flight to Bangkok was at 7 PM, we reached Bankok at 8:40 PM, we had our Hyderabad flight at 10 PM, we reached Hyderabad at 12 AM IST time, thus we ended our memorable tour :) :) :) :) This blog page is to inspire people to visit beautiful Phuket.

Karon Beach:

Jars required to get response from JSP using HttpUnit (ServletRunner/ServletUnitClient)


I encountered various exceptions when I a wrote a HttpUnit test to call a servlet which dispatches the request to another JSP. I downloaded the required jars and updated the build path, then it worked. Below are list of jars I used:
  • el-api.jar
  • httpunit.jar
  • jasper-el.jar
  • jasper-jdt.jar
  • jasper.jar
  • js.jar
  • jsp-api.jar
  • junit-4.10.jar
  • nekohtml.jar
  • tomcat-6.0.33-tomcat-juli.jar
  • xercesImpl-2.6.2.jar

Example Servlet:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.RequestDispatcher;

public class TestServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) {

RequestDispatcher rd = request.getRequestDispatcher("jsp/index2.jsp");
request.setAttribute("test","mymessage");
try{

rd.forward(request,response);
 }catch (Exception e){
  e.printStackTrace();
 }
}
}

JSP: (present in "jsp" folder)

<% out.println("Forwarded JSP output"); 
out.println(request.getAttribute("test"));
%>

Web.xml:

<web-app id="WebApp">

<servlet>
<servlet-class>TestServlet</servlet-class>
<servlet-name>WebStandard</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>WebStandard</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>

</web-app>

Example test:

@Test
public void testJSP() throws IOException, SAXException{
ServletRunner runner = new ServletRunner(new File(getClass().getResource("web.xml").getFile()));
ServletUnitClient client = runner.newClient();
WebConversation wc = new WebConversation();
System.out.println(client.getResponse("http://localhost/test").getText());
}

Output of Test:

Forwarded JSP output
mymessage

Wednesday, September 12, 2012

JMeter - Distributed testing using JMeter


   
        This post will help you to configure JMeter servers across various machines. Before we dive into the step-by-step instructions, it's a good idea to define the terms and make sure the definition is clear.


Master – the system running Jmeter GUI, which controls the test.
Slave –  the system running jmeter-server, which takes commands from the GUI and send requests to
the target system(s).
Target – the webserver we plan to stress test.

There will be 1 Master JMeter and Multiple Salves with JMeter Server running on them. Below image will give you some picture -

Copy all JMeter folders to desired slave machines. As part installation of JMeter create environment variables for JMETER_HOME and JMETER_BIN in all the slave machines (even on Master machine).

Step-by-Step

Prerequisites - 

  1. The firewalls on the systems are turned off.
  2. Environment variables are defined for JMeter (JMETER_HOME, JMETER_BIN)
  3. All the machines should be on same subnet. 
  4. Use same version of JMeter to avoid unanticipated errors/issues.

On Slave Machine:

  1. Go to jmeter/bin directory and execute jmeter-server.bat (jmeter-server on unix). If there is any error during server start up check for environment variables related to JMETER, check if the error is related to RMI and check if multiple JRE versions are installed, then do the modifications mentioned from step 2 to 4. else if there is no error during server start up it will be like below screenshot (ignore steps from 2 to 4)-

  2. Open jmeter-server.bat in a text editor
  3. go to line 44 and find “:setCP”
  4. edit “START rmiregistry” to the full path. Example: “START C:\\jre\bin\rmiregistry”

Verification of server on slave machine - 

To check whether server is started successfully or not on slave machine, check below line in jmeter-server.log - (you will know more details from the log )


jmeter.engine.RemoteJMeterEngineImpl: Starting backing engine on

If you do not see this message, it means jmeter-server did not start correctly. (may be due to some firewall blocking RMI Traffic (it can be windows firewall or antivirus firewall)  )


On Master Machine - 

  1. On master system acting as the console, go to jmeter/bin directory open jmeter.properties in a text editor.
  2. edit the line “remote_hosts=127.0.0.1”
  3. add the slave IP addresses. For example, if I have jmeter server running on 10.19.129.38, 39, 40, 41, and 42, the entry would like like this: remote_hosts= 10.19.129.38, 10.19.129.39, 10.19.129.40, 10.19.129.41, 10.19.129.42
  4. Start jmeter.bat to open JMeter master GUI.
  5. Open the test plan you want to use.
  6. Start threads on client machine as mentioned in below screenshot -


To start on all remote slaves (when you have more than one slave), you can select Remote Start All option. Master JMeter will gather results from slaves and display the results using Listeners that are included in the test.

One of the major drawback which I've observed in practice is if you have any config elements which reads data from files, for example CSV Data Config (reading data from CSV), such files will not be sent to Slave machine during running the test. If you have such config elements and you run the test, the test will fail. So such files needs to copied to appropriate folders on Slave Machines. When compared to Load Runner (LR), in LR Controller this will be done automatically.


Thursday, June 21, 2012

JMeter - Overcome/Remove Maximum number of redirects


By Default JMeter performs maximum of 5 redirects, but whenever if your application performs more than 5 redirects JMeter will throw below error during script execution -


Error in JMeter:

Response code: Non HTTP response code: java.io.IOException
Response message: Non HTTP response message: Exceeded maximum number of
redirects: 5


To overcome the error we have to change property value of httpsampler.max_redirects in jmeter.properties file in /bin directory, do the following steps -

1. Change the value of the property to 20
2. Remove # before httpsampler.max_redirects
3. Save the file
4. Restart JMeter

Property value will be as below after the change -

# Maximum redirects to follow in a single sequence (default 5)
httpsampler.max_redirects=20

That's all now JMeter will be able to redirect up to 20 auto redirects.

Happy Learning!!!

Friday, June 15, 2012

JMeter - Passing variable values between two requests or samplers

As I've started working on JMeter and I thought it would be good to share it on blog rather than keeping it with myself. OK, so first thing I want everyone to understand the basic components that are used in JMeter, the below picture can (as picture is worth a thousand words) help you understand it and you have to get used to JMeter jargon before we start off with any basic preparation. I would like to call the pic as JMeter-Halo as it give basic idea about the components of what we use -

JMeter Halo:

Pic Source

Now, let us dig in, in the example I've taken a W3Schools web service to build the test plan in JMeter rather than developing my/our own web service and deploying it in the server, this will save us some time. Web service WSDL is hosted at link W3Schools Temperature converter. I hope you are able to install and launch JMeter successfully and this is the prerequisite. 

The main flow can be achieved with below 5 steps -
  1. We will add the WSDL to JMeter and will send first request for 1st Method CelsiusToFahrenheit using WebService(SOAP) request sampler.
  2. We get the response and parse the Response for the output fahrenheit value using XPath Extractor. We will have to provide XPath Query 
  3. We store the output fahrenheit value in a user defined variable.
  4. We will send this output fahrenheit value in second method request of FahrenheitToCelsius using BeanShell Pre-Processor component.
  5. Verify the response of the second method request. 
Steps to create test plan in JMeter -

1. Launch JMeter.
2. Create Thread Group under Test Plan as shown in below screenshot -

3. After adding Thread Group specify below inputs to  
  • Give some Name to Thread Group 
  • No.of threads as 2 (that means two users)
  • Ramp Up Period as 1 (each thread will be started with a time gap of 1 second)
  • Loop Count as 2 (total no.of iterations for each thread/user)
So it will be same as below screenshot -



4. Now after specifying the no.of users, add WebService SOAP Request for 1st Method by Right Clicking on Thread Group -> Add -> Sampler -> WebService(SOAP) Request and modify the request sampler as -
  • Specify Name for the request.
  • Give WSDL URL in WSDL URL Field.
  • Click on Load button. Methods will be displayed in Web Methods drop down. For doing this step check whether you are behind any firewall. If you are behind firewall specify proxy IP and Port value. Specify Proxy IP address in Server Name or IP field and Port value in Port Number field.
  • Now select method CelsiusToFahrenheit from Web Method drop down and click on Configure button, JMeter will populate values in the fields.
  • Provide Celsius value as 150 and save the test plan and the final request will be as mentioned in the below screenshot.

5. Now as mentioned in the main flow, we have to capture the output value from the response so to do this we need User Defined Variables. To add it go to Thread Group -> Config Element -> User Defined Variables. After adding the element, you can add variable by clicking on Add button. Give some name let us say "output_g" will be the variable name, if you wish to put some default value then you can put the value in Value column, any description for the variable then you can put the description in Description column, so after creating variable it will be click as below screenshot - 

6. Now you can run the test to check whether Request is in correct format or not, but before you run the test add "View Results Tree" Listener by right-clicking on Thread Group -> Add -> Listener -> View Results Tree. You can also save results to a file. 

(check below screenshot)


7. Now go to Run -> Start (or Ctrl + R) to start the run. After the test finishes you can view the result response for each thread  in "View Results Tree" as below -



8. we got the results now we have to extract the Fahrenheit value from the response and store it in the variable "output_g", to do this we need to use XPath Extractor. Now right click on CelsiusToFahrenheit Request -> Add -> Post-Processors -> XPath Extractor. We have to use XPath to extract the value from the response. We are using post processor because a post processor will be executed after the request is executed. (Sequence of execution will be pre-processor, sampler element, post processor)

XPath will be - 
/Envelope/Body/CelsiusToFahrenheitResponse/CelsiusToFahrenheitResult/text()

Populate variable name "output_g" in Reference Name field. That means XPath Extractor will extract the value from the response and store it in output_g variable. 

When XPath fails to extract the value, the default value will be stored in output_g variable. In our case I've put "null" as default value, so when XPath fails it will populate null in output_g variable.



9. Till now we've completed sending first request and capturing response value, now we have to shift to preparing second request to convert Fahrenheit to Celsius. To do this right click on Thread Group -> Add -> Sampler -> WebServie(SOAP) Request. Load the WSDL link which we have used on step 4 and click on Load WSDL button and select FahrenheitToCelsius from drop down and click on Configure button and the values will be populated automatically.

Let the request name be - 
FahrenheitToCelsius Request

Request structure as below -

 <?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
     <FahrenheitToCelsius xmlns="http://tempuri.org/">
       <Fahrenheit>#string#</Fahrenheit>
     </FahrenheitToCelsius>
   </soap:Body>
</soap:Envelope>




If you observe the request carefully I've used tag "#string#" this is where we have to populate "output_g" value in the request dynamically. To do this we need a pre-processor for this request. So first pre-processor gets executed and then actual request will be sent. To add Bean Shell Pre-Processor, right click on the request -> Add -> Pre Processors -> BeanShell Pre Processor.


Give some meaningful name to it, let us say - FahrenheitToCelsiusBeanShellPreProcessor.

So you may get a question, what is "bean shell"? and the answer is -> BeanShell is lightwieght dynamic java compatible scripting language (just like Groovy Script, which we do it SoapUI tool), you don't have to compile the code every time you change it, everything is taken care during run time and we can also use Java classes here too.

In BeanShell Pre Processor you have to write your script in Script text-area. Below is the script that you have to use to get the value of output_g and replace #string# with output_g value. To get the value of any variable in JMeter we have to use vars.get("variable_name") and to change the value of the variable you have to use vars.put("variable_name","value"). "sampler" is a variable provided by JMeter and refers to the parent WebServiceSampler, in our case it refers to "FahrenheitToCelsius Request" sampler. We get the XML data of the request by getXmlData() method and replace #string# with output_g value. After replacing the value we have to set the new XML data using setXmlData() method.


import org.apache.jmeter.protocol.http.sampler.WebServiceSampler;

// type cast sampler object to WebServiceSampler.
WebServiceSampler   ftocRequest = (WebServiceSampler)sampler; 

log.info("----------------VALUES WE GOT START-----------------------");
log.info("java global bean shell value= " + vars.get("output_g"));
log.info("----------------VALUES WE GOT END-----------------------");

String replacedRequestXMLString = ftocRequest.getXmlData().replace("#string#", vars.get("output_g") );

ftocRequest.setXmlData(replacedRequestXMLString);

log.info("XML data set" + replacedRequestXMLString);


We can add more listeners to view the consolidated reports of the users like View Results in Table or Summary Report by right clicking on Thread Group -> Add -> Listeners context menu.

You can run the test now and see the results in "View Results Tree" listener as mentioned in the below screenshots. 

Request screenshot - #string# is replaced with output_g value.
Response screenshot - 150 is returned in the response.
So that's it! we are able to send the variable value in the second request and get the response. Try it and Learn it!

Happy Learning! 


Sunday, January 31, 2010

URI, URL, URN: Difference between URI and URL

There is lot of confusion between URL, URI and most of the people are still unaware of the distinctions. I started a little research on it. I provided information related to URI, URL, URN. Here we go:

I found the following at the W3C's Contemporary View of Uniform Resource Identifiers:

"...a URL is a type of URI that identifies a resource via a representation of its primary access mechanism (e.g., its network "location"), rather than by some other attributes it may have. Thus as we noted, "http:" is a URI scheme. An http URI is a URL. The phrase "URL scheme" is now used infrequently, usually to refer to some subclass of URI schemes..."

However, as is typical with W3C documents and specs, there's a little too much technical mumbo-jumbo floating around in that explanation to satisfy anyone who doesn't balance their checkbook in binary, so I kept looking. Kenneth Fly's Web Site provided the following:

"URI stands for Universal Resource Identifier and URL stands for Universal Resource Locator. Often times people use the terms interchangably, which is not entirely correct. A URL is a subset of the URI popular protocols. These are protocols (http://, ftp://, mailto:). Therefore all URLs are URIs. The term URL is deprecated and the more correct term URI is used in technical documentation. All URIs are means to access a resource on the Internet and are a a technical short hand used to link to the resource. URIs always designate a method to access the resource and designate the specific resource to be accessed."

So...the terminology is apparently way out-dated and I need to start saying "URI" instead of "URL." Why? Because anything that has been deprecated is bad news.

From various other Sites:

· Whereas URLs always refer to network addresses (including a protocol specification, host name or address, and local path), a URI does not necessarily refer to a remote resource. For example, the URI file:///c:/ specifies a local directory. Because file does not refer to any specific network protocol, this URI is not also a URL. (Check with, A URL is a subset of the URI popular protocols. These are protocols (http://, ftp://, mailto:) as mentioned in the above paragraph)

RFC by Tim Berners – Lee: http://www.faqs.org/rfcs/rfc2396

As mentioned in the RFC 2396, the abbreviation terms Uniform, Resource, and Identifier are straight forward. Tim was conveyed how they divided URI into URL and URN.


Uniform:

Uniformity provides several benefits: it allows different types of resource identifiers to be used in the same context, even when the mechanisms used to access those resources may differ; it allows uniform semantic interpretation of common syntactic conventions across different types of resource identifiers; it allows introduction of new types of resource identifiers without interfering with the way that existing identifiers are used; and, it allows the identifiers to be reused in many different contexts, thus permitting new applications or protocols to leverage a pre-existing, large, and widely-used set of resource identifiers.

Resource:

A resource can be anything that has identity. Familiar examples include anelectronic document, an image, a service e.g., "today's weather report for Los Angeles"), and a collection of other resources. Not all resources are network "retrievable"; e.g., human beings, corporations, and bound books in a library can also be considered resources. The resource is the conceptual mapping to an entity or set of entities, not necessarily the entity which corresponds to that mapping at any particular instance in time. Thus, a resource can remain constant even when its content---the entities, to which it currently corresponds---changes over time, provided that the conceptual mapping is not changed in the process.

Identifier:

An identifier is an object that can act as a reference to something that has identity. In the case of URI, the object is a sequence of characters with a restricted syntax.

A URI can be further classified as a locator, a name, or both. The term "Uniform Resource Locator" (URL) refers to the subset of URI that identify resources via a representation of their primary access mechanism (e.g., their network "location"), rather than identifying the resource by name or by some other attribute(s) of that resource. The term "Uniform Resource Name" (URN) refers to the subset of URI that are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable.

To read more: http://www.faqs.org/rfcs/rfc2396.html#ixzz0eAl5m8dL

The important point in URL is the “Network Location” as mentioned in the example which provides the distinction:

For example, the URI file:///c:/ specifies a local directory. Because file does not refer to any specific network protocol, this URI is not also a URL.

Computer scientists may classify a URI as a locator (URL), or a name (URN), or both. A Uniform Resource Name (URN) functions like a person's name, while a Uniform Resource Locator (URL) resembles that person's street-address. In other words: the URN defines an item's identity, while the URL provides a method for finding it.

The ISBN system for uniquely identifying books provides a typical example of the use of URNs. ISBN 0486275574 (urn:isbn:0-486-27557-4) cites unambiguously a specific edition of Shakespeare's play Romeo and Juliet. In order to gain access to this object and read the book, one would need its location: a URL address.

From technical point of view as mentioned in Wikipedia:


A URL is a URI that, in addition to identifying a network homed resource, specifies the means of acting upon or obtaining the representation, through description of the primary access-mechanism, or network "location". For example, the URL http://www.wikipedia.org/ identifies a resource (Wikipedia's home page) and implies that a representation of that resource (such as the home page's current HTML code, as encoded characters) is obtainable via HTTP from a network host named www.wikipedia.org. A Uniform Resource Name (URN) is a URI that identifies a resource by name, in a particular namespace. One can use a URN to talk about a resource without implying its location or how to access it. The resource does not need to necessarily be network homed. For example, the URN urn:isbn:0-395-36341-1 is a URI that specifies the identifier system, i.e. International Standard Book Number (ISBN), as well as the unique reference within that system and allows one to talk about a book, but doesn't suggest where and how to obtain an actual copy of it.