Saturday, June 30, 2012

Lunch @ Fisherman's Wharf Bangalore

Recently heard about "The Fisherman's Wharf" and thought of trying it today. After the usual Saturday shopping went to the restaurant for Launch buffet.

For me the initial and most important perception points when visiting any restaurant are :

  • Car Parking
  • Time to get seated
  • Time to take the first order

Car parking was well organized and assistant was also available. Front desk staff was really quick and got a good table with in minutes. The restaurant was crowded. Luckily I thought of calling in advance otherwise wait for the table could have been long.

There was a Kannada star in the adjacent table (I think it was Sudeep). luckily he, staff and other guests were acting normally.

Rating : The ambiance is very good
9/10

Food is good. Options for Welcome drink was beer or mock-tail. Only Fosters was available, I hope they will add more varieties.
8/10

http://thefishermanswharf.in


Monday, June 25, 2012

TwLauncher 'Force Stop' issue

Yesterday I realized that the desktops in my Samsung Galaxy S is full and for most of the applications there are 3 to 4 links in the desktop (thanks to my daughter). So started a cleanup work by moving the unnecessary links to the recycle bin.
I was hoping that the phone may be faster once I finish the cleanup, but to my surprise phone stopped responding !!

'Force Close' error message for the TwLauncher started coming continuously. It was not possible to access any applications, settings etc but phone functionality/ contacts was ok. The smartphone almost became a brick.

From Android experience I knew that some how if I reset data for the TwLauncher things should work but the problem was that it was not possible to go to the 'Manage Applications' link.

But finally after couple of painful hours I managed to make my phone work again.
Following are the steps (for other urfortunate guys using TwLauncher)
  1. Try to invoke google search box. This can be done by pressing and holding the context menu button.
    But you will have to really fight with the 'Force Close' messages as they will be repeatedly appearing.
    Keep on trying this , if you are lucky after sometime the search box will appear.

  2. Ensure that the mode of the search box is 'Apps' (mode can be changed by clicking the button to the left of search box ).

  3. Search for "setting ", this will launch the Settings

  4. In Settings, go to 'Applications' -> 'Manage Applications' -> 'All' tab

  5. Select TwLauncher app from the list and click 'Clear Data', this will recover the phone.

Other options considered are
i. Install another launcher like 'GO Launcher'
   This may not help if the issue already occured, but it will be a good idea to install such alternate launcher to help in future.
'Go Launcher' is available for free from Google Play 

ii. Cleaning the TwLauncher data in USB mode
Try connecting the phone to Laptop in USB mode, if this works then the Launcher data can be cleared.

iii. Factory reset
This is the last option if nothing else works.

Note: Your custom screens may be lost once you clear the TwLauncher data.

Are you looking for good free Android educational application for Preschoolers?
Try this - https://play.google.com/store/apps/details?id=com.fortytwo.mathapps.kidsnumberlearning.activity
Review is available here - http://crashingnhanging.blogspot.in/2013/08/android-free-preschooler-number.html


Saturday, June 23, 2012

g|days in India

Finally google days event in India !
Venues are Chennai, Bangalore, Hyderabad, Delhi and Mumbai

Since the space is limited , register today itself.
For details visit : https://sites.google.com/site/gindia12/

Tuesday, January 31, 2012

Introduction

JMock is the famous library which can be used for working with Mock Objects.
(Please check www.MockObjects.com to know more about Mock Objects.) . How ever you might be excited to know that Mock Objects are not just Stubs!! They give a different approach to unit testing.
So finally testing is also becoming as interesting as Coding.
In simple words we can say that a mock object is something which can be used for testing the behavior of other objects. It will mimic the behavior of an actual class / interface.
A Mock object can also observe how other objects uses its methods and compare with the expected behavior. (I will explain this in detail with code sample.)

This means that we can test and verify how our class uses the available environment. 
Let's assume you are developing a Customer class which has to interact with a BookShopclass. But unfortunately BookShop class your friend is developing and as usual it is not available yet. So naturally we will decide to use a Mock Object of BookShop instead of an actual instance. 
Customer has function doTransaction().
BookShop has methods pay(Money) , Book getBook()
Using JMock we will be able to specify that getBook() is always called only after pay().
So if anywhere in our doTransaction method if getBook is called with out pay() it will result in an error with bright red colour while testing it. 
This way we can ensure that our class uses the available interface in the desired way.
In a TestDrivenDevelopment environment this means that interface problems can be found even before the actual coding of it starts.
JMock makes our life easier by creating mock objects dynamically and providing features to specify expectations (How it should behave, etc).


Download Link

The JMock jar/zip can be downloaded from www.JMock.org
This can be added as external jar file in your Eclipse project.

Using JMock

Here comes the interesting part!
Lets develop as class called DispFile , which is a highly useful class for displaying a given file in console.
DispFile class uses the IFileHandler interface for the file operations .
Code for IFileHandler

public interface IFileHandler {   public void open(String filename) ;   public void close() ;   public String read() ;    } 

Code for DispFile 
public class DispFile {     public DispFile()  {     }    
     /**      * Business method to display the given file line by line      */     public boolean display(String filename)  {         
  Boolean status = true;         
  try   {             
   IFileHandler fileIntf = new FileHandler();             
   fileIntf.open(filename);             
   String line = null;             
   while ((line = fileIntf.read()) != null)    {                 
    System.out.println(line);             
   }            
   fileIntf.close();         } catch (Exception e)    {             
  Status = false;         
 }        
 return status;     } } 

 Here the line "new FileHandler" is the problem! We know the actual implementation is not yet available. So we have to use a MockObject for IFileHandler instead of an actual instance.  We must change the class to make it testable . The changes are minimal and it is a low price to pay for getting the testability with Mock Objects. This refactoring also makes the design cleaner.  The modified code is given below. 


public class DispFile {   
... /** Business method to display the given file line by line */   
public boolean display(String filename) {    
Boolean status = true; 
Try {     
IFileHandler fileIntf = getFileHandler();     
 ....       
}catch (Exception e) { 
Status = false 
}     
return status;  
 }   
/**   Its true that this method seems nonsense, but it is very important forUnit testing with Mock Object technology. */ 
protected IFileHandler getFileHandler() {  
return new FileHandler(); 
}    
} 

Code for Test Class 
package chkJMock;  
import junit.framework.TestCase;  
import org.jmock.*;  
public class DispFileTest extends MockObjectTestCase {   
/ *    * Test method for 'chkJMock. DispFile.display(fileName)'    */   
public void testDisplay() { ....   }  
} 

We will check the code             required in testDisplay method in detail. 


//set up the Mock Object .
//First we have to set up the context             in which our test will execute.
//We have to create a DispFile to test. We             have to create a mock IFileHandler that       
//should receive the message. We then             register the mock  IFileHandler with the DispFile.
Mock mockFileHandler = mock(IFileHandler.class); 
final IFileHandler intf = (IFileHandler) mockFileHandler.proxy();     
DispFile df = new DispFile() {      
protected IFileHandler getFileHandler() {        
// I hope now the use of silly looking getFileHandler method is clear.          
return intf;
// expectations     
// Here we specify how DispFile class is expected to use the IFileHandler interface.      
//     
// The method open should be called only once with the argument file (String            // containing name of the file to display).     
String file = "E:\\@Com XML CorbaTask.xml";     
mockFileInterface.expects(once()).method("open").with(eq(file));         
//     
// The method close should be called only once and it must be called after the method       
// open . (Unless you want to close a file which is not yet opened! ).     
mockFileInterface.expects(once()).method("close").after("open");      
// The method read should be called one or more times (we are reading lines in a loop.)     
// It should return a null string when it is invoked.     
mockFileInterface.expects(atLeastOnce()).method("read").withNoArguments()     .will(returnValue(null));         
// execute     
// Call the business method we were waiting for     
boolean status;     
status = lf.list(file);     
assertTrue("Error displaying file : " + file, status);  
This when executed ensures that the methods in the interface (Mock object ) are invoked in correct order and in specified way. If anything is violated (e.g- if close is called without calling open , open called multiple times ) , it will result in test error.  

Note :

To mock concrete class jmock-cglib extension and cglib jar should be added to the eclipse project. Testcase should derive from cglib.MockObjectTestCase.
Eg:-          
Mock mockTaskDetailsClient = mock(TaskDetailsClient.class,"mockTaskDetailsClient");  
final TaskDetailsClient taskDetailsClient = (TaskDetailsClient)mockTaskDetailsClient.proxy() ;   
ctr with args. mock(TaskDetailsClient.class,"mockTaskDetailsClient", class[],Object[]); 
There are many tools/ services available now which will help in generating unit test for the existing legacy code base. One such service is www.UnitTestFactory.com
 

Tuesday, July 12, 2011


The top 7 reasons to love JBoss AS7:
(taken from JBoss AS7 webinar)

1) Blazing fast start-up time - up to 10X faster!

2) Java EE 6 - leading the pack. again.

3) Very lightweight - exceptionally small footprint and aggressive memory management mean you can run it practically everywhere.

4) Modular core - delivers true application isolation.

5) Elegant management - simplified console and APIs.

6) Domain management - manage servers as groups.

7) Testable by design - simplified in-container testing via the Arquillian project speeds development.

I hope some body from WAS team is also reading these data :)


Tuesday, March 15, 2011

Hacking Tool for Dummies - FireSheep


You might have already heard about FireSheep - an interesting FireFox extension.

It can be used to intercept unencrypted cookies from websites by using Packet Sniffing.
In plain english - if you are accessing sites like Facebook, Twitter in a public Wifi , a person using FireSheep extension can find out what you are doing and may be even impersonate you as the FireSheep user may get your login credentials.

It is developed by Eric Butler and currently available for Mac OS X and Windows.
More details can be found here http://codebutler.com/firesheep

Tuesday, February 1, 2011

Another tool from Google - AppInventor, I'm loving it.


Hope you guys heard about Google App Inventor.
It is tool for developing Android applications , all you need is browser (and internet connection).

To use the tool you need to register with Google.

There are mainly three parts to the App Inventor

1. Designer Part - This is the main application which will open in the browser window.
Here we can drag and drop different components (e.g.- buttons, images, media etc) to design our own application.

2. Blocks Editor - This window can be opened from the Designer window. Here we will be mentioning what are the expected functionality of the different components we added in the designer part. For example - what should happen when the button is clicked.
If the intention is to play a music file when the button is clicked , then we will be dragging and connecting different blocks like button.onClick mediaFile.play

3. Simulator - what fun it is if we can not see our world class application in action. Simulator is for that. It can be opened through the blocks editor. What ever changes we are making in the Designer and Blocks editor will be visible in the simulator.

There are couple of tutorials in Google to get started with App Inventor.
I had developed a paint program with out writing a single line of code :)

But do not get all excited, AppInventor is still in Beta state. There are many functionalities missing. I was really surprised at the long list of missing things. For example - there is no way to add menu items. How can Google miss out such basic features? (even if it is Beta version).

Important Links



Note that instead of using simulator you can also connect your mobile. But I would recommend to use the simulator and once the basic application is ready install it in the phone.

The different steps to install application (apk file) in the phone are

1. From the AppInventor, package the application in the computer.

2. In phone go to settings and enable installation from unknown source.

3. Connect the phone to computer as USB Mass storage.

4. Copy the apk file to phone.

5. Phone should have a file manager application. If you are not having one, download a file manager application from Android market (for example - Astro).

6. After this click on the copied apk file in the phone and select the option Open with TaskManager, this will install the application.