Friday, December 19, 2008

How to intentionally fail a particular call to get 404 in Fidller ???

See earlier post and adds " *bpafter" as action for auto-responder rule. It will return 404 for any call.

This allows the request to hit the server, but break on the response... So finally we get 404 :-)

*bpu : Break on request before hitting server : This could also be used...

Wednesday, December 17, 2008

How to fail a particular HTTP call through Fiddler?

I am a Quality Engineer who test a lot of things in softwares. Currently I am working on a hybrid application where a desktop software make some internet calls.

Recently I came across a scenario where I wanted to fail a particular call in middle of a set of HTTP calls. Fiddler helped me to do so.

Here are the steps to make this happen:

I am taking an example for explaining this. Lets take a case where one thread make 5 calls Call-1, Call-2....Call-5 and I want to fail Call-3. Here are the steps I need to follow:

- Run this thread after starting fiddler.
- It will list all five calls.
- Select Call-3 and select AutoResponder Tab on the right side
- Check the option for "Enable Automatic Responses"
- Click Add Button
- Call-1 URL will be listed in Rule Editor in Right-Bottom
- Enter any random value in other text-box on the right side of Rule-Editor.
- Save this.

In future whenever you will run this thread, Call-3 will always fail.

All the Best!!!

Sunday, November 16, 2008

Fundas of Contiguous Memory Allocation - Part I

Through Contiguous Memory Allocation, the memory manager strictly allocates contiguous memory locations to an object loaded in the memory. The Contiguous Memory Allocation can be done in two ways, static and dynamic.



In the Static Memory Allocation, the memory is divided into equal sized partitions and objects are loaded into these partitions as the processes ask for them. With this type of memory allocation, we see a fragmentation that is known as internal fragmentation that occurs when a small object is loaded into a partition of a larger size. The space that is not occupied by the object cannot be allocated to another object and hence is wasted.

In case of Dynamic Memory Allocation, the internal fragmentation is eliminated by making each partition only as large as necessary for a particular object. When an object is removed from memory, the space occupied by it is returned to the pool of available memory spaces. However, in this case, a fragmentation known as External Fragmentation is observed because over the time, dynamic partitioning 0f memory has a tendency to fragment memory into interspersed areas of allocated and unused memory. As these areas are not contiguous, allocation may fail to find a free region to honor a request, even when the combined size of the free memory exceeds the need of the object by a wide margin.

Another type of fragmentation that can be seen in case of contiguous memoy allocation is the table fragmentation. This is attributed to the space occupied by the data structures needed for operation of the memory manager.

Thursday, November 13, 2008

Windows 7

1. Why 7 ?
>> Its 7th OS from Microsoft. Seventh release of Windows.

Other 6 Windows Operating Systems:

Windows XP
Windows Vista
Windows 2000
Windows 98
Windows ME
Windows 95

Main Features:

Windows 7 includes a number of new features, such as advancements in touch, speech, and handwriting recognition, support for virtual hard disks, improved performance on multi-core processors, improved boot performance, and kernel improvements.

- Improved Wordpad
- Improved Calculator Functionalities
- New look to Media Centre

Many new items have been added to the Control Panel including: Accelerators, ClearType Text Tuner, Display Color Calibration Wizard, Gadgets, Infrared, Recovery, Troubleshooting, Workspaces Center, Location and Other Sensors, Credential Manager, Biometric Devices, System Icons, Windows Solution Center, and Display.

-- Some applications that have been included with prior releases of Microsoft Windows, most notably Windows Mail, Windows Movie Maker and Windows Photo Gallery, are no longer included with the operating system; they are instead offered separately as part of the Windows Live Essentials suite. --

For more details CLICK HERE

Wednesday, November 12, 2008

Result Codes in Fiddler

In Fiddler UI you can see two sections, on the right side and other on Left. Left section list all web sessions. In Web Sessions section you can see different Results for different web calls.

The following Result codes quickly discuss each HTTP status that you can get back, what it means, and what to do about it.

301 — Moved Permanently

This HTTP status means that a redirect was used – and that the redirect told the browser that the redirect would remain in effect indefinitely. The URL that the web browser asked for has permanently moved to a new location. This may mean that your application is referring to a directory on the web site without a final slash. So if the reference is http://ripple4photography.blogspot.com/search/label/Light the reference should be http://ripple4photography.blogspot.com/search/label/Light/ because blog isn't a file it's a directory.

302 — Object Moved

This type of status is a temporary redirect. This is the kind of redirect that most developers are familiar with. It tells the web browser that the object has temporarily moved to a new location. These are normal for applications that post back to the same page, validate the input, perform the operation, and then redirect the user to another page. These generally don't represent a problem unless there are a lot of them.

304 — Not Modified

This type of status indicates that the web browser asked the server if the image had been modified since the browser had cached it. The browser sent a request for the file but indicated in the request that it had a cached copy and that the web server shouldn't bother sending it back unless it changed. This typically indicates that the cache control headers aren't present in the responses the browser is receiving. As a result it caches the response but has to check with the web server to see if its cache is still valid. This can be a performance problem. Since not a lot of data is transmitted it doesn't have a huge impact on overall bandwidth, however, because there can be many of these requests the latency of each call to check whether an image has changed or not can add up to a significant wait time for the user. By setting caching headers in the response that the browser receives these 304 statuses can all be eliminated.

400 — Bad Request

This status code means that the web server didn't understand the request from the client. Although this occurs rarely it can be a problem if it's occurring frequently. This typically points to components integrated into the web server, such as ISAPI filters, which are mangling the request but can sometimes point to poorly encoded data in the request.

404 — Not Found

This status message is the most infamous status on the Internet. It means that the web server couldn't find the content that was requested. If this is the main page that the user has requested this will be obvious as they get a 404 page. However, if it's for a JavaScript file, a CSS file, or other supporting files for the page, the user may not know anything is wrong. The best solution here is to track down the references and update them.

500 — Server Error

This status message is a bit more ominous than the others here. It's more ominous because it means that the server wasn't able to complete the processing of the request. This can indicate a greater server problem or at the very least instability that should be addressed. As with other errors it may be hidden in an embedded object and can be easily missed.

502 — Connection Issue

This status message indicates that a connection message couldn't be made to the server. This could mean that the name wasn't translated or that there are problems in the underlying transport of packets to the server. Either case indicates a broader networking issue. You'll need to make sure that you have thoroughly tested the underlying network before continuing to debug the issue.

200 - Successful web requests :-)

What is Fiddler?

For last few months I have using Fiddler for my testing. Actually I used to test some hybrid application where a desktop application interact with multiple online servers for different purposes. So Fiddler helped me to track different http calls between desktop and online servers.

Fiddler is a HTTP Debugging Proxy which logs all HTTP traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP Traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

Fiddler is freeware and can debug traffic from virtually any application, including Internet Explorer, Mozilla Firefox, Opera, and thousands more.

Fiddler is the electronic equivalent of an X-Ray that can get into the traffic going between your web application and the web server to make sure that everything is OK. Fiddler can tell you what was wrong in a specific interaction and can show you at a glance what problems there are with the overall conversation. It's an invaluable tool for anyone who develops web applications — no matter whether that development is in .NET, Java, Cold Fusion, or some other language.

Thursday, October 30, 2008

How to read a file in PERL

The open() function

Data files are opened in Perl using the open() function. When you open a data file, all you have to do is specify (a) a file handle and (b) the name of the file you want to read from.

As an example, suppose you need to read some data from a file named "checkbook.txt". Here's a simple open statement that opens the checkbook file for read access:

open (CHECKBOOK, "checkbook.txt");

*** Use complete filepath. Generally its a good practice. Replace single slash with double slashes in file-path

In this example, the name "CHECKBOOK" is the file handle that you'll use later when reading from the checkbook.txt data file. Any time you want to read data from the checkbook file, just use the file handle named "CHECKBOOK".


Example - opening a data file and reading from it

Now that we've opened the checkbook file, we'd like to be able to read what's in it. Here's how to read one line of data from the checkbook file:

$record = ;

Pretty simple, eh? After this statement is executed, the variable $record contains the contents of the first line of the checkbook file. The "<>" symbol is called the line reading operator, and in this example we've put the checkbook file handle in the line reading operator, indicating that we'd like to read a line from the checkbook file.

Of course, instead of reading just one line of data, you may want to operate on many lines of data in the checkbook file. Suppose, for example, you wanted to print every record of information from the checkbook file. Here's the code to (a) open the checkbook file, (b) print each record from the file, and (c) close the file when you're finished working with it:

   open (CHECKBOOK, "checkbook.txt");

while ($record = ) {
print $record;
}

close(CHECKBOOK);

Notice the use of the close() statement in this example. You always want to close a file when you're finished reading from it, and since the while loop reads through the entire file, there's not much else to do when you're finished except close it.


Wednesday, October 29, 2008

Operators in PERL

I assume that examples used will explain about the usage of operators here.

1. Equality Operators :


Strings:
if ($Name eq "Ripple") { print "My Name is $Name" }
if ($Name ne "Ripple") { print "My Name is not $Name" }

Of course it would make more sense to use else here, but for the sake of examples be happy with this solution.

Numbers:
To compare numbers, use <, <=, >, >=, <> and ==.



2. If...then...else...elsif

$MyAge = 24

if ($MyAge < 18)
{ print "My age is less than 18" }
elsif ($number < 25)
{ print "My age is less than 25" }
else { print "My age is greater than 25" }

OUTPUT:
My age is less than 25

Simpler way to right If statement:

$Name = "Ripple";
print "My Name is Ripple" if $Name eq "Ripple";

Another way to use if-else:

$Size eq "Big" ? $output="BIG" : $output="small";
print $output;

if it is true, the code after the question marked will be executed. If not, the code ofter the colon will be executed. So if your if block only needs to do one statement, use "? :"



3. FOR loop...

for ($counter = 0; $counter <= 10; $counter++)
{ print $counter."," }
Output:
0,1,2,3,4,5,6,7,8,9,10,

$counter++ means, that $counter will be increased one by one and is short for $counter = $counter + 1. You can also use it with a minus, making it $counter- - . But you can do a little bit more while you are in a loop.

Place any of the commands into the loop and you con do this:

last Exit the loop immediately
redo Repeat the last run in the loop
next Proceed to the next run, don't run any command after this in the loop

The main use for those is, if you have to change the standard loop behaviour under special circumstances or rules, when you want to abort the loop and so on.

Some Basic things about PERL

1. PERL is Case sesitive...

2. What can I use Perl for?
Most people use PERL for either automating administrative tasks (write a .pl file and launch it with PERL.EXE) or in combination with a webserver to create dynamice web pages. Most UNIX based webservers have PERL support already integrated (like APACHE) whereas you have to install PERL on WIN32 platforms like Windows NT (IIS 4).

3. Variables are declared with a $

4. prompts for input and stores the value in the according variable

print "Your age please $firstname $lastname: ";
$myage = ;

5. How to define an array in Perl?

@myarray = ("red","green","black");

OR

@myarray = qw(red green black);

OR

$myarray[0] = "red";
$myarray[1] = "green";
$myarray[2] = "black";

6. Hashes in Perl:A Hash consists not only of onebut two values each - a KEY and a VALUE.
To initialize a hash write:
%myhash = ( "Name" => "Vijay Kumar Sharma",
"Hobby" => "Photography",
"Age" => 24
);

OR

$myhash{'Name'} = "Vijay Kumar Sharma";
$myhash{'Hobby'} = "Photography";
$myhash{'shoe size'} = 24;

*** Note Curly braces for hash keys...

foreach $key (keys %myhash) { print $key.": ".$myhash{$key}."\n"; } ==>> Ignore if not able to understand at this moment... I have to separately see how for loop works in PERL

Monday, September 22, 2008

C++ Questions ???

1. What are the four functions that compiler automatically provides? How can you prevent compiler to provide automatically?

>>

-
default constructor
- copy contructor
- assignment operator
- destructor

Friday, September 19, 2008

Friend in C++

In some circumstances, it is more convenient to grant member-level access to functions that are not members of a class or to all functions in a separate class. You can declare friend functions or friend classes to access not only public members but also protected and private class members.

The friend keyword allows a function or class to gain access to the private and protected members of a class.

Wednesday, September 17, 2008

Access Specifiers in C++

With C++, you can specify the level of access to member data and functions. There are three levels of access: public, protected, and private.

Access Specifiers:


Public : Available to everyone

Private : Class members declared as private can be used only by member functions and friends (classes or functions) of the class.
If someone tries to access a private member, they’ll get a compile-time error.

Protected : Class members declared as protected can be used by member functions and friends (classes or functions) of the class. Additionally, they can be used by classes derived from the class.