Friday, 22 November 2013

Jmeter for performance Testing

Running Soap services in Jmeter for performance testing:

Apache JMeter is an Apache project that can be used as a load testing tool for analyzing and measuring the performance of a variety of services, with a focus on web applications. 

Apache JMeter may be used to test performance both on static and dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET, etc. -, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.

Apache JMeter features include:
Ability to load and performance test many different server/protocol types:
Database via JDBC
Message-oriented middleware (MOM) via JMS
Mail - SMTP(S), POP3(S) and IMAP(S)
Native commands or shell scripts

Adding thread user in test plan 
Add >>Thread >> Thread group

>> Give thread group names
>> Number of threads [How many instances of the service file you wanted to run for performance testing]
>> Ramp up time [This is the time need to initialize all the threads in system]
>>Right click on thread group >>Add >>Sampler >>Soap XML/RPC request
>>Give name to the service in [name] box .
>>Give full url of the service for ex- [http://localhost:8181/testService]
>>Copy wsdl file content into [soap/xml-RPC Data] field

>>Save it.  [You are done]. 

>>Add a listener to view the performance of your service or program. There are varieties of listener. These 2 are good for analyzing the soap services performance. 
1) View Result tree 
2) Aggregate report 

You can add various types of result as : 
>>Right click on your newly added soap/ xml-rpc request >> add >> listener

Run the project and view the result in listener.

Returning the the node value of xml service as a variable:
you can return the xml node value into a Jmeter variable & use it at other different places by various types of postProcessors. 
For returning simple node value into a variable you can use regular expression extractor as below.
>>Right click on Soap-xml/rpc request 
>>Add >>Post Processor >> Regular expression extractor
>>Give Reference name [this will act as your variable] for ex - myVar
>>In regular expression box type <nodeName>(.*?) </nodeName>
(.*?) is a regular expression which will return any value in between <nodeName> tag.
>> In template add $1$
>>Save it.
>>Now you can use myVar at any other place as ${myVar}

Happy Learning 
Cheers !!

Saturday, 9 November 2013

Using Regular expressions in notepad++

--Using Regular expressions  in a practical life --

Hey Guys, Today i was writing a post & come with a particular problem. The problem was , I was writing 108 names of God Surya. I wrote them one by one in every new line in notepad. Later I thought I forgot to add OM as a prefix to each name. Now what to do? I can not type  each name & add one by one.

So for that I thought to use techniques of regular expression & add them in intelligent way. So what I did was, I opened that file into Notepad++ .
Then pressed Ctrl+H to open find & replace box . At the search mode, i selected the option "Regular Expression" .

Now at "Find what" box - I typed "^"  ==>This indicates beginning of each line 
and at "Replace with box" - I typed  "OM ". Finally I clicked on Replace all. 

That's it.  In one shot, i did my whole changes.  Wow it was fantastic.

Similarly,  if you have text like

and  you wanted to make  some thing like -
test: "word1"
test: "word2"
test: "word3"

All you need to do is 
Search = ^([a-Za-z0-9]+)$
Replace= test:"\1"

This is just a very simple example of using regular expression in notepad++. You can do much better things  related to matching & replacing various types of patterns by using regular expressions.

Happy Learning.. ..!!

Saturday, 14 September 2013

Setting up apache maven

Abstract: Apache Maven has been build to resolve your day to day problems for adding many dependencies that exists in project from various source. Basically, In java you have many dependency to be added to the system. So, It becomes very difficult to manage them by searching Jar files & adding manually to project.
For example - You may need Spring Jars in your project, than after some time you may need Struts Jar. To bring all them in common place in library in your project manually is very complicated & length task. The Maven helps you to add Jars for you making central repository.
All you need to do is add/Modify the POM.XML file.
1) Download the latest version of apache maven
currently the version is 3.1.0.
2) Extract the tar or zipped folder & Preferably place it at  
"C:\Program Files\Apache Software Foundation" location 

Now add M2_HOME an environmental variable , & set the path to where it is placed. 
If you are using windows 7, Follow
        Right click on Mycomputer--> Properties -->Advanced System Settings -->Environmental variables 
In User variables section
Click new ==>Set variable name to -->M2_HOME 
               SET variable value to -->
C:\Program Files\Apache Software Foundation\apache-maven-3.1.0

(Path of maven folder)

In the same dialog box -- Add new variable M2 
 SET PATH TO : %M2_HOME%\bin

Now add the same M2 varialle to the end of your path variable too. 

Make sure you have JAVA_HOME variable set to Java jdk path
 C:\Program Files\JAVA\jdk1.7.0_17 
SET THE PATH VARIBLE TO its   bin directory  as 

Open a command terminal & type : 
mvn --version
It will show you the current version. That's all folks, you get Maven Installed.

In Next Post, I will show you how to create project through Maven add dependency to it. 

Stay tuned.
Happy Learning. :) 

Sunday, 25 August 2013

Most Useful Eclipse Shortcuts for Java

1)  Ctrl + Shift + R.  -->Open any file quickly

2) Open a type (e.g.: a class, an interface) without clicking through interminable list of packages: Ctrl + Shift + T

3) Go directly to a member (method, variable) of a huge class file,     Ctrl + OCtrl + Shift + ↓ or Ctrl + Shift + ↑,  ==>to move up & down

4) Ctrl + L, enter line number.  

5) Go to a supertype/subtype: Ctrl + T.
6) Help ⇒  Help → Help Contents → Java Development User Guide → Reference → Menus and Actions

Wednesday, 24 July 2013

Some useful Linux commands on Ubuntu

Some useful Linux commands on ubuntu: 

-r  (Recursive , it applies to all directory & sub directories )
Changing the Permission of the file .
chmod -r 777  /var/www/chicagoKid

Configuring Automatic DHCP when it is not configured by default when internet is not working :

ifconfig  - a  //Check IP  is shown or not

In order to configure DHCP address you will need to edit the 'interfaces' file /etc/network/interfaces .

auto eth0
iface eth0 inet dhcp

ctrl+c => cancel
ctrl+o ==>writer out //in terminal
Ctrl+x ⇒   Exit or quit .

Go to /etc/init.d/networking restart   // To restart network services

1)  you can use editor vi or gedit  to open any file.
2) User sudo whenever you need permission.

if you are required to be owner for all time, just open terminal and type
sudo nautilus


Check the ubuntu wheter 32 bit or 64 bit:
uname -a
Result for 32-bit Ubuntu:
           i386 GNU/Linux
whereas the 64-bit Ubuntu will show:
                        x86_64 x86_64 GNU/Linux

file /sbin/init

Creating Directory:

sudo mkdir -p /usr/local/java

Some useful commands:
pwd  :  print working directory
ls ~  → Shows file in your home directory
CD (Change Directory)
"cd /"     ⇒ Naviagate to root.
cd ~  ⇒ Navigate to home
cd .. ⇒  one level up
cd -  ⇒ Previous directory

cd ~/Desktop   ⇒ will move you to desktop directory

1) cp file foo  ==>Copy file & name it foo
2) cp -r directory foo == >Copy recursively the directory & paste into foo directory.

mv foo ~/Desktop   ==>Moves file  foo to desktop

rm: Use this command to remove or delete a file in your directory.

rmdir: The removes empty directory. To delete all directroy & its content use -r (recursive options)

mkdir ⇒ Make directory
man : ⇒ Lists Manual of other commands
eg : man mv ⇒ Will bring mv manual
sudo: The sudo command is used to perform file operations on files that the Root User would only be allowed to change.
df : File system disk spaces  usages  -h(human readable ) -s means "Summary"
free: tells amount of free and used space  -m(using megabytes)
 top ('table of processes')  : Displays running processes and system resources.
tab  : Auto completes any command

Paste  into terminal:
ctrl+v does not work  ⇒ User ctrl+Shift+v

History  : Lists command that you already typed

Add new user:
adduser newuserName
passwd  yourNewPassword

Sunday, 23 June 2013

PHPUnit - Unit Testing in PHP

Guys, How many of you are familiar with unit testing in PHP? Well coming to PHP, every would say Yeah every one does it, through echo or die and exit; testing individual modules or functions. Many of us has perception that my code works well so there is no need to test it.

Well, if  you are inline across with same idea, it's what we are not been addicted of the advantages of unit testing frameworks. Instead of testing manually each and every case all time, why not we do it through automation in unit tests right? Further more , When you are under going for a product development, it really comes handy when you are required to know, how much resource a particular module is taking up. Will this module be influencing the other modules performance too? All these things has to be analyzed carefully for a successful product development at each at every stage.

The one which am I talking here is about PHPUnit testing framework which was initially inspired JUnit testing framework for Java. Well if you are PHP Geek, or amateur , you would not take much time to learn this framework and use it .  Here  I'm going to write basics about PHPUnit and simple example  to demonstrate  its usage. Without further ado lets dive into it.

PHPUnit should be installed using the PEAR installer. You need to bother about all those. I would suggest you to download XAMPP  with latest version with PHP version 5.4+ . Below 5.3.3 the PHPUnit does not work. 

I am assuming this article for windows users, Linux users can have slightly different commands. After Installation of XAMPP, there are slight  updates required to be done  in the pear package. 

Go  command line installation directory of PHP, Run it as Administrator.

If you have installed your XAMMP in F drive: 
do the following:
1) Type: F:  then press Enter
 you will be directed to F drive , then type 
  CD F:\xampp\php> 
Here you will run the PEAR command to for updating and installing some dependent package of PHPUnit. 

First one is installing -   PHP_CodeCoverage" package that does not come with the xampp itself. So install it type :  

pear channel-discover pear channel-discover pear install phpunit/PHP_CodeCoverage 
Press the enter , it will be installed automatically. 

If you face any problem, then you need to make sure that your pear package is up to date. To update the Pear package type: 

pear update-channels 
It will update your pear package, the repeat the same above command.

You might face some problems relating to update too. Update may be failed because of caching problems. If you find like so , clear the cache of pear as 

pear clear-cache

That's it you are done with the installation, now for testing your script all you need to do is 

Type the command 
phpunit "FullAbsolutePathOfYourFile"      
Example : F:\xam\php>phpunit "F:\xam\htdocs\test\PersonTest.php"  

Here i will show you how will you write the test script for you actual class being tested. 

Before you dive into details for testing, you need to understand basic idea about it.  The basic idea about  testing in a very nutshell is very simple. Take an example; you have a certain class having function to add 2 numbers that returns sum of it. Now, we need to ensure that the sum is correct ie. 2+3 should yield 5. So the sum = 5 is the result we expect from that function. That means in  our testing class we need to write our testing which compares our expected output with the real output of the function. If the expected out put comes equal with that, our test result passes. That's it, all about the testing. This is the very generalized concept in a nutshell.  

Lets understand it by our example: We have a class person, when  he talks, we should expect the result as Wecome guys or some thing else whatever may be , but we do not expect the sound like MEW as cat right?  


class Person{
    protected $name;

    public function getName() {

        return $this->name;

    public function setName($name) {

        $this->name = $name;

    public function talk() {

        return "Welcome guys !";


So we would like to write  UnitTesting Class for this function, which ensures that only man has spoken and not an animal.  To do so,  we write a class PersonTest which must extend PHPUnit_Framework_TestCase class


class PersonTest extends PHPUnit_Framework_TestCase

      // test the talk method
     public function testTalk() {
         // make an instance of the person
        $person= new Person();
        // use assertEquals to ensure the greeting is what you
        $expected = "Welcome guys !";
        $actual = $person->talk();
        $this->assertEquals($expected, $actual);



assertEquals is a method built in PHPUnit testing framework class which will compare if both the output are equal. There are many methods.

Now run this PersonTest.php class through command line as  

F:\xam\php>phpunit "F:\xam\htdocs\test\PersonTest.php"  

you will see the output something similar to as below. 

That's it You are done with the unit testing with PHP. Wow. !! Congrats.

Couple of things to note.

If test is successful,  you will  see the little dot there.  For every test run there will be a character indicating the result. The characters are as follows:
  • . – Printed when a test succeeds.
  • F – Printed when an assertion fails.
  • E – Printed when an error occurs while running the test.
  • S – Printed when the test has been skipped.
  • I – Printed when the test is marked as being incomplete

This is just an introduction to PHPUnit testing, you need to dive more detail on it. Please do refer an official PHPUnit testing manual here for further detail

Don't forgot to send your feedback enjoy up. !!!



Friday, 12 April 2013

CSS tricks on styling fonts

Styling CSS using External Fonts:

This might be simple thing  if you know the tricks on how to add desired fonts to the web server, but some times if you are new to this situation, it may stuck you for a while.

Take a simple example, the client want to have Helvetica font into his site. You may be smarter enough to add the helvetica font like 

         font-family: helvitica;

But it will not work, because Helvetica is not enlisted in default font list. Your browser will try to find the source for Helvetica font, when it does not find it , by default it will take Arial font which is some what similar to it but not exact.

Another thing to notice is , Helvetica is not a free font , you need to pay ($30- $50) for it. Wow, now what to do !!! 
Often every  one loves Google, so hit the search for Helvetica font. When you find it , download . This  might be in the form of fontName.ttf extension, again  you can not use this font for the web purpose  because it is not web compatible format . So you need to convert this into web compatible formats like - .eot, .svg, .woff, & .ttf too. For achieving this task, you can get some online web sites where you can submit your font & get the converted file attachment back with the compatible fonts.

Obviously, you don't want to loose money for just a font, if you are freelance. So hold down, take a glass of water & long breathe. Here is the way.

You can use this site-   , Add the font here & Convert.

After converting & getting all the useful web fonts , you can add these fonts to your web server in some directory or create your own directory & name if fonts/ .

Now After doing this task, all you need is, to add below script to the top of your css file as below.

@font-face {
font-family: 'Helvetica';
src: url('fonts/helvetica.eot');
src: url('fonts/helvetica.eot?#iefix') format('embedded-opentype'),
url('fonts/helvetica.woff') format('woff'),
url('fonts/helvetica.ttf') format('truetype'),
url('fonts/helvetica.svg#helvetica') format('svg');
font-weight: normal;
font-style: normal;

A simple example of using  Helvetica Neue CE35 Thin font 

       Now your helvetica font has become fully functional . Include this css file & style your document with the font name give at the top. 

Note: you can give any name of your desire,  to the font you have newly added, But don't forget to give the same name while styling the document with classes or IDS. 

I hope this document will be surely helpful ,when you get drown into styling the fonts. Any feed backs, & suggestions are hearty welcomed. Enjoy up..!!!

Wednesday, 20 March 2013

Dynamic Data with Modal Pop Using Jquery

You might be interested in getting Pop up window with dynamic data from the Database. One of the common usage you may come up with is:
Suppose you have a student record table, where you are storing detail information about the student. Then you will be obviously having the View student functionality in your application. Here you want to display all the detailed information about student. It's good choice to display all the information about the student, but unfortunately your window size is fixed, so you need to display only important fields of the student record such as Student Name, Address, Contact Number, & Faculty.

Displaying only necessary information has two advantages - One when you look at the student display page, you should not feel like it is too complex, & second important thing: the lesser you display the content , the more faster will be the students records executed.
So, When  you wanted to view the complete details of student, Just give a link to a student name or Id. When it is clicked  display the modal pop up with complete detailed information about the student. Couldn't this quite interesting?

Okey, Diving deep into coding, it pretty easier. Lets check it out.

Say you have list of names & when click on any name, you want to display pop up with his complete details.

So here you have queried through DB & inside loop you have some thing like-
   <a href="#" onclick="pop_up('<?php echo $customer['user_id']; ?>')" >
           <?php echo $customer['first_name']." ".$customer['last_name'];?>

When you click on any name, we are passing an Id inside a    java script function  pop_up() .
So the pop up function will receive an Id & through where , I  will Post the id to Php Script using Jquery.
The Php will  select the required data & return back to the same page.  

<script type="text/javascript" src=""> </script>

<script type="text/javascript">

function pop_up(id){

var url = "customer_complete_datail.php?id="+id

$.post(url, function(data) {
 $('#overlay_form').html(data);  //Setting the content of html 
//open popup


             function positionPopup(){

               function close_cd()
$("#overlay_form").fadeOut(500); //Closing the opened window

Just create the space using DIV for holding you dynamic data 

<div id="overlay_form" style="display:none;">

Give some styles in html head section for Pop up Model:

position: absolute;
border: 5px solid gray;
padding: 2px 24px 2px 2px;
background: white;
/*width: 321px;*/
/*height: 400px;*/

display: block;
border: 1px solid gray;
width: 65px;
text-align: center;
padding: 6px;
border-radius: 5px;
text-decoration: none;
margin: 0 auto;

Here is the Page (customer_complete_detail.php) that we are referencing & getting the whole content:

include_once '../config/connect.php';
include_once 'helper.php';
$Helper_admin = new Helper_admin();

$id = $_REQUEST['id'];

$customerDetail = $Helper_admin->getCustomerDetailById($id);
<html xmlns="">
    <title>Customer Details</title>
    <style type="text/css">
        background-color: #f3f3f3;
        border: solid 1px #a1a1a1;
        padding: 10px;
        width: 300px;
    .formLayout label, .formLayout input
        display: block;
        width: 120px;
        float: left;
        margin-bottom: 10px;

    .formLayout label
        text-align: right;
        padding-right: 20px;

        clear: left;
    <div class="formLayout">
        <h4 class="h4_account">Customer Details</h4>
        <div class="pop_up_form">
       <label>First Name:</label>
       <label><?php echo $customerDetail->first_name; ?></label>
       <label>Last Name:</label>
       <label><?php echo $customerDetail->last_name; ?></label><br>
       <label>Contact No.:</label>
       <label><?php echo $customerDetail->contact_no; ?></label><br>
       <label><?php echo $customerDetail->user_email; ?></label><br>
       <label>Current Location:</label>
       <label><?php echo $customerDetail->current_location; ?></label><br>
       <label><?php echo $customerDetail->city ; ?></label><br>
       <label><?php echo $customerDetail->state ; ?></label><br>
       <label><?php echo $customerDetail->country ; ?></label><br>
       <label><?php echo $customerDetail->zip  ; ?></label><br>
           <a href= 'javascript:void(0)' onclick="close_cd()" id='close_cd'>Close</a>

So you are almost done.  !!! Hurray ..

Here is the output when you click on one of the name :

Any Questions.. Queries.. Don't forget write out  !!!
Rock up.. :) !