Wednesday, 14 October 2015

Spock Framework with spring , spring boot , hsql in memory db

To Start with disclaimer , I am new to Groovy so the syntax I used in this might not be the best practice but that shouldn't be problem as that is the not the problem statement.

Sample Project

The sample project is available on git.

Code is self explanatory . Basically I have tried to test a repository ( inserts data in in memory hsql db which is injected through Spring boot )  and stub a LDAP service which is normally called as part of authentication.

Version of frameworks used 

The best way to explain this section is to specify the pom I used

Integration with spring boot

It was smooth . The only hurdle was we can't use @SpringApplicationConfiguration  but need to use @ContextConfiguration directly as shown in the below code . This is the groovy  specification which is used for testing.

I have tried to cover

  • Simple Test case of null check
  • Data Driven Test (DDT)
  • And usage of mock 
A small hack which was needed to be done in case of DDT specially when using DataTables . It didn't allow for cases in which exceptions do occur . Its again self explanatory in the code.  


I personally found using spock with spring seamless . It was not only easy but due to its groovy influence it was much easier to write .

It incorporates the ease of mockito and brings in new features specially when it comes to mocking like the use of regular expression .

Loved the verbose nature of the failure scenarios which was pretty self explanatory.


At the end of my work I also found another really nice ebook :

Wednesday, 4 March 2015


                                           SUBSCRIBE ISSUE WITH GEMFIRE (CONNECTION CONNECTS                                                     AND DISCONNECTS )

Lately this evening I got stuck with an issue with one of or Gemfire Clients not able to subscribe to our gemfire cache.

We are using CQ Services of Gemfire to give our external client to query our cache .

Now one of our client informed us that post their overnight release they are not been able to  get any updates from our gemfire cache.

On looking deep into the logs of our Gemfire it seemed like their system was connecting and disconnecting again and again , this process of connection creation and disconnection was continuously happening but there weren't any more errors on our side.

With having no clue on our side , we tried to replicate the scenario in our lower ENV's

Here we asked the same client to connect their lower ENV to one of our lower ENV , increase their logs to level of trace , increase Gemfire logs to 'all' .

Once they connected and our cache attempted to send them the data as part of subscription notification , we were able to replicate the problem of connecting and disconnecting system .

But as the logs were at their deepest level , we noticed an exception on their side .

Now this exception was due to their own wrong code ( it was a business level exception ) , which they weren't catching properly.

Now once they fixed this issue , and reconnected to our server , they were able to get updates from our server and the issue of rigorous connection-disconnection also stopped .

So what I Assume  : If a client level application exception occurs , gemfire subscription process stops the subscription and tries to connect again and again try to publish the same message . This was causing the connecting-disconnecting problem to appear .

So if someone is too facing the same problem , they can increase the log levels on client side and analyze that log for more info. 

Wednesday, 18 February 2015

View Contents of keystore Java without knowing keystore password - stolen idea!!

                                                            Contents of Key Store

This evening at work , my jenkins  release stopped working .

Reason : It was building properly but was not able to release to artifactory . Upon investigation and beating my head around , found that the certificate used for the connection b/w jenkins and artifactory had expired.

So I had to import new certificate to my JDK cacerts . But before doing it I wanted to view the contents of my cacerts.

Viewing was easy ,

                          keytool -list -keystore <keystore-location>

but then it asked me for the keystore password and as most of the times i didnt remember it.

So falling back to the basic option : GOOGLE

3rd link pointed me to a wonderful code at


The code helped me to create a new keystore with a new password and after this I ran the keytool code again and woooosh everything was there.

Little bit of hack but helps in dire needs.