Monthly Archives: January 2013

Working with easymock

Redchilliplus's Blog

Like it or not, you will find your class using some legacy singleton code. Problem begins when you try to unit test your class. Lets dive into some example and see how to write unit test for such a class. is typical singleton implementation. Our new class is using Singleton.

Lets assume that the is user for the Singleton.

If you try to run following Junit test, it will throw exception because Singleton will try to load file from some relative path which is not available in your unit test.

Problem here is Singleton because it is trying to load properties from a defined location, in real world it may be getting database connection, JMS connection or having remote reference of an EJB. With all these kind of initialization in private constructor, we can not unit test singleton with simply using mock object.

To unit test, we…

View original post 166 more words

Cool, save it for later usage 😉

Show me the code! - By Davanum Srinivas

OUTDATED SAMPLE – Updated code is here:

Using Smack XMPP API from Android

Once you get tired of the limitations of android’s built-in IMProvider and the corresponding API – IXmppSession and IXmppService, try the sample below. Inside the source/binary zip (bottom of this article) you will find a smack.jar that works with android. To build the jar yourself, You can download the Smack 3.0.4 sources from here and apply the patch here.

Here is a screen shot of the XMPP Settings Dialog.



  • For GTalk, use “” as host with port 5222. The service name is “”

  • Don’t add “” in the user name, just the id will do

Here’s the code for the settings dialog

Here is a screen shot of the main window.



  • In the Recipient field, make sure you add the “”, not just the user id

Here’s the code for the main activity

View original post 8 more words

[ANDROID] Place cursor at the end of text in EditText

Place cursor at the end of text in EditText

how  ? 

myEditText.append(“text abc”);

this will set ( actually appending )  new content into edit text, then place the cursor at the end of the edit text.