Caution with Java Autoboxing


Experimenting new blog

I'm experimenting a new blog powered by Hugo static site generation at . Have a look and give your feedback....

Simple Introduction to Scalaz

Scalaz is a great library to make your Scala code more compact and to reduce some boilerplates. But getting started with it requires considerable effort. With its large collection of different operator and very functional nature most people are afraid to use it. Specially for people like me who are with more imperative programming background, it is not easy to get familiar with scalaz.

Recently InfoQ published a presentation named "Scalaz for Rest of us" by Adam Rosien, which introduces some basic building blocks of scalaz. Explanations are really simple and will help you to shed your fears on scalaz.


Trying out Eclipse Kepler

Yesterday I downloaded the new version of Eclipse IDE; Eclipse Kepler.

So far the experience is great. It is much faster than Juno. Main problem I had with Juno is that it is damn slow even with the updates provided later by eclipse to fix the slowness issue. But Kepler seems to have fixed all those issues properly.

Most notable improvement for me so far is the improved Eclipse Marketplace. Now we can select multiple plugins once and do the installation together.  Previously we had to install plugins one-by-one. And also conflict resolution related to plugin installation had been improved. Previously when there is a conflict, eclipse only tell that installation cannot be completed, but now it says exactly which plugin causes the problem and gives option to continue installation without it.

One problem I had was that there is no official support for Scala-IDE for Kepler. But managed to find a scala-ide build from scala-ide google group. It was working fine, so until official version is available I'll be able servile with it.

Alternative for Google Reader, Feedly

Google has announced that they are going to discontinue Google Reader from 1st of July 2013. It is really sad news since I use reader everyday to keep up-to-date with various blogs.

After seeing this news, first thing I wanted to do was to find and alternative. First one I came across is Feedly.  It is a web based reader and has plugins for chrome, firefox, safari and apps for android and iOS. Best thing with Feedly is that you can login with Google account and it will automatically import all your feeds from Reader. After getting used to the UI, it seems to be really nice tool. For the moment I'm going to use Feedly.

I'm also thinking about finding a good desktop reader as well. Since I'm using Linux there are lot of readers available. Have to try some and find a good one. 

Changing System Time in Xen VM

Yesterday I wanted to change the system time in one of our test servers. Server was a Xen VM running redhat linux.  I used date --set="20 Dec 2012 00:30:00" command, but when I checked the date again it showed the previous date not the date I've set using date command. 

After doing some searching I found out that by default VM clock is synchronized with its host Xen Server; so changing date is not possible. We need to disable this time synchronization before updating date in the VM. To do that I had to execute following command in VM linux console.
/sbin/sysctl -e xen.independent_wallclock=1

After that I was able to change the system time using date command.


Stubbing Asynchronous Http Services using Wiremock

Wiremock is simple library which can be used to stub Http Services. It is a handy tool when you want to write unit tests against some Http service(eg: Http REST web service). It has direct support for JUnit using @Rule feature. We can write unit tests to stub different http requests and verify those requests and responses very easily.

One weakness of wiremock was it only supported synchronous  http request mocking(i.e: You send the request and stubbed wiremock server send the response). But I wanted to mock Asynchronous REST server. In asynchronous scenario in addition direct http response, server is initiating another call back request to the server. This method is commonly used by web service operations which take lots of time to process. Flow of such operation would look like follows.

When a client want to get some operation done;
  1) Client sends the request to the server
  2) Server accept that request and give that accepted response as direct http response
  3) Server do the processing and send the actual result as a new http request to the client

This feature is implemented in my wiremock forked repository. Still this is not being merged to main wiremock repository. So if you are interested in this you'll have to clone my forked repo, build it locally and publish the jar file to your local maven repository.

Stubbing asynchronous request is easy.

In most asynchronous http services, some kind of Id is being used to map original request with the asynchronous response. There can be two ways of doing this.
  1) Server generates transactionId and sends it with the immediate response
  2) Client sends the transactionId and server echo that when it sends back asynchronous response

If you want to use the second method with wiremock, you can use setEchoField method.

At the moment there is a one limitation with this. You can only use this facility with JSON requests and responses.

You can find the complete test class at github.

Tribune to Heros

Tribune to Heros
We will never forget the sacrifices you made to protect our country....


Get Google Toolbar Button

Enter your email address:

Delivered by FeedBurner