Month: February 2013

My prototype development experience with Magento

Magento is an ecommerce framework vendor where we recently developed a prototype. I started off with installing Magento Community Edition from http://www.magentocommerce.com/download

Magento offers demo data as optional installation. If you are installing for first time it’s recommended to also download the demo data.

Before installing you need a Wamp or XAMP installed on your windows machine. If you install the latest version it may not be supported as yet so do check the System Requirements from http://www.magentocommerce.com/system-requirements page before copying downloaded files in your web folder. Load the sample data in magento database and point to your browser to magento web folder. Rest of the installation is straightforward and once you setup the passwords you are done.

Browse to the admin panel and there are plenty of things to configure from extensions to add-ons to third party integrations. The crux of the magento is in these configurations. Once configured the payment method and other customizations you are done! Now next step is to add modify the product catalog. Since we loaded the sample data its already there. Your first magento application is now ready.

If don’t want to do even these steps there is a easier way out to directly go for hosted solution checkout http://go.magento.com/plans/

Conclusion: eCommerce app development couldn’t get easier than this!

JMeter Introduction for beginners…

What is Jmeter?

Apache JMeter is used as a load testing tool for analyzing and measuring the performance of a variety of services of web application.

Jmeter is a java based open source software tool.

JMeter can help you to do regression testing of your application by creating test scripts for web services.

JMeter runs in two modes:

  1. GUI mode (which runs on windows)
  2. Non-GUI mode (which runs on Linux)

 

Use of Jmeter?

JMeter can be used as a unit test tool for database connections, web services, etc.

Jmeter uses to test the load and performance of the web services.

Running Jmeter in GUI mode (which runs on windows)

Installation:

1. Install Java run time in your PC
url:- http://www.java.com/en/download/index.jsp

2. download Jmeter release.
url:- http://jmeter.apache.org/download_jmeter.cgi

3. Extract in your specify folder like as C://
run the file (C://jakarta-jmeter-x.x/bin/jmeter.bin)

Start the Jmeter interface, i.e. jMeter windows batch file from bin folder.

 

How to run JMeter?

Steps to run JMeter are as follows,

  1. Start JMeter windows batch file from bin folder, it will open interface as shown in below:Image
  2. Create your first test plan by creating thread group:Image
  3. Added Thread group:Image

Here thread group consists of 3 main properties,

a. Number of threads(users): It consists of number of requests you want to run in one test plan.

b. Ramp-up period (in seconds): It tells us how long all requests takes time to run. If there are multiple requests, then all requests get run one by one.

c. Loop count: It shows count that all requests get run in how many loops.

All samplers and listeners are involved in thread group.

4. Adding sampler:Image

Samplers describes that “Jmeter sends web requests to server and wait till response comes.”

5. Sampler (e.g: Http Request):Image

In this sampler, you can add parameters to send request to server to run the service.

6. Add listener:Image

Listener,  where test data and result get stored and it displays the output in different ways. Here added listener is “View as a tree”.

7. Run the test plan with result tree:

Now Select listener and run the test plan.Image

In this listener, output gets display in detail with,

a. Sample result: Where load time, sample count get displays to you.

b. Request: What request you send to server.

c. Response data: The exact output comes from server.

8. Run the test plan with result table: Here, table shows all results in tabular form with no. of requests and average time for all requests.Image

In this way your simple test plan of a web service get executed.

Consuming Webservices & Parsing JSON Response Tutorial :Part 2

Hi Folks,

This is the Part 2 of  Consuming Webservices & Parsing JSON Response Tutorial

Previously we have consumed webService using NSURLConnection and got the response successfully .

Now time to parse the JSON response and populate data on UITableView.So the question is Is There any external library to parse raw JSON string?

Yes, there is numbers of external JSON framework which makes developers job easy.For this tutorial we are going to use SBJson framework

You can grab this framework from here and if you have not read part 1 just go through it here

How to install JSON framework?

The simplest way to start using JSON in your application is to copy all the source files (the contents of the Classes folder) into your own Xcode project.

  1. In the Finder, navigate into the Classes folder.
  2. Select all the files and drag-and-drop them into your Xcode project.
  3. Tick the Copy items into destination group’s folder option.
  4. Use #import “SBJson.h” in your source files.

Parsing Raw JSON

The first thing you should do, if you do not understand exactly what’s going on, is to NSLog thedescription of the JSON parser output. This will be a “list” of NSDictionary and NSArray, and when you see the description output you will understand that there is a one-to-one mapping of JSON “object” to NSDictionary

I have created one method where my parsing logic goes

declare it in .h file

-(NSMutableArray *)parseJsonResponse:(NSString *)rawJsonResponse;

in .m file implement this method as

-(NSMutableArray *)parseJsonResponse:(NSString *)rawJsonResponse

{

NSArray *responseKeyValueArray;

NSError *error;

SBJSON *json = [[SBJSON new] autorelease];

NSDictionary *responseKeyValueDict = [json objectWithString:rawJsonResponse error:&error];

#if DEBUG

NSLog(@”JSON parsing responseKeyValueDict: %@”, responseKeyValueDict);

#endif

if (responseKeyValueDict == nil)


{

#if DEBUG

NSLog(@”JSON parsing failed: %@”, [error localizedDescription]);

#endif

}

else {

if([responseKeyValueDict  valueForKey:@”list”] )

{

responseKeyValueArray  =[responseKeyValueDict  valueForKey:@”list”];

#if DEBUG

NSLog(@”responseKeyValueArray ::%@”,responseKeyValueArray);

#endif

if ([responseKeyValueArray isKindOfClass:[NSArray class]])

{

NSMutableArray *artistdetails = [[NSMutableArray alloc]init];

for(int i=0;i<[responseKeyValueArray count];i++)

{

NSDictionary *keyValueIndex = [responseKeyValueArray objectAtIndex:i];

#if DEBUG

NSLog(@”keyValueIndex::%@”,keyValueIndex);

#endif

Artist *artist=[[Artist alloc]init];

artist.imageName=[keyValueIndex objectForKey:@”image”];

artist.artistName=[keyValueIndex objectForKey:@”name”];

#if DEBUG

NSLog(@”artist.artistName::%@”,artist.artistName);

#endif

[artistdetails addObject:artist];

[artist release];

}

#if DEBUG

NSLog(@”artistdetails %d”,[artistdetails count]);

#endif

return [artistdetails autorelease];

}

else

{

return nil;

}

}

}

return  nil;

}

Call this method in connectionDidFinishLoading .modify it as

– (void)connectionDidFinishLoading:(NSURLConnection *)connection

{

// do something with the data

// receivedData is declared as a method instance elsewhere

NSLog(@”Succeeded! Received %d bytes of data”,[receivedData length]);

NSString *responseString = [[[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding] autorelease];

NSLog(@”Succeeded! Received JSON String %@ “,responseString);

// parse raw json response

parsedResponseData=[self parsedJsonResponse:responseString];

// release the connection, and the data object

[connection release];

[receivedData release];

}

Now we have Artist information, populate data over UITableView.To achieve this reload tableview and modify you cell for row method as below.

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellIdentifier = @”ArtistCell”;

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

}

if([parsedResponseData count]!=0)

{

// Configure the cell.

Artist *a = [parsedResponseData objectAtIndex:indexPath.row];

NSLog(@”artist name isin cellfor index path %@”,a.artistName);

NSLog(@”artist image link is %@”,a.imageName);

cell.imageView.image=[self displayImage:a.imageName];

cell.textLabel.text=a.artistName;

}

else

{

if(indexPath.row==0)

{

cell.textLabel.text=@”No Data”;

}

}

return cell;

}

 

To display images to UIImage of table view cell add and implement one more method

-(UIImage*)displayImage:(NSString *)imageUrl

{

NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageUrl]];

UIImage* image = [[UIImage alloc] initWithData:imageData];

return image;

}

Done 🙂

Note:Although you might expect some UI Freeze while scrolling as there is no Lazy Loding of image.To resolve this just keep it your uitableview scroll disable.

Hit run and  output looks like this

 

Artist List

Your first Windows Store App

It is been a while Windows 8 is out, and being a techie, I was more than excited to use Windows 8. Yes, there are so many exciting features which include the Tiles, the Metro Interface! By the way I don’t think I am the only one who had a hard time getting used to the Start button as well as Settings button which is at the right pane or “Charm Bar!” 🙂

When overall UI is explored and observed, it was time to get into the actual Windows 8 App Development. Maybe it is my early days of development in Windows 8, but still, I found it interestingly amazing!

So, if the excitement is triggered above the limits, let us get started with your first app in Windows 8!

Prerequisites:

  • Microsoft Windows 8 (obviously!)
  • Microsoft Visual Studio 2012 with Developer License
    • Particularly, developer license is required to get the things going with Windows Store. It won’t allow you to develop any app unless you have the developer license.

So, when the prerequisites are finalized, let us develop the first “Hello World” app.

Steps to create your first Windows Store app:

  • Open Visual Studio 2012
  • Goto File Menu -> New -> Project..

You will be presented with the following screen

app1

Select Windows Store from Visual C#.

Out here, you have so many options for an app, for now, we will go for a Blank App (XAML)

  • Give a name for your app. Click Ok. You will be able to see a screen where App.xaml.cs is opened for you. This file, particularly, controls the whole operation of your app.
  • From the solution explorer, open the MainPage.xaml file. The following screen is displayed.

app2

As we have selected the blank app, you are able to see this blank “Slate”. You are able to design whatever you want from here.

  • Let us do some designing!From the toolbox, which is at the left pane, select a “Text Block”. If you’re an asp.net developer this is “label” for your understanding!  Drag and drop TextBlock.I always like to use the split view in Visual Studio, as you can see, if you’ve added the TextBlock, immediately changes in xaml code are also reflected. In quick succession, I assign the fontsize property to my TextBlock for making it appear a little big!

app3

  • So, in quick Succession, insert a button, which will be displaying a “Hello World” when clicked on it. The current TextBlock will be “My First Store App”.
  • Insert another TextBlock  and make it invisible.  So, finally you will be having the following screen.
    app4
  • Lets do some simple code.
    I just generate a click event for the button by double clicking on it, make another TextBlock visible to show our message, in the following code.
    One of the most crucial steps, which we often forget is to assign a TextBlock with “Name” property. Particularly, in Windows Store Apps, this particular step should not be missed.
    app5
  • The code:
    app6
    Note how the visibility property is used.
  • To see the result, click on the drop down arrow besides debug.
    app7
  • You can have a selection between a Simulator, Local Machine and Remote Machine.I prefer simulator. So, click on simulator to run your first app!It will build deploy and present you the app.First Screen:
    app8
    When clicked on “Click Me” button, you get presented with the following Screen
    app9

That’s the very first Hello World App you created for Windows Store!

Hope you liked it! 🙂