Posts in java

Using PowerMock + TestNG to Mock a Static Class

 This week I needed to test a class that depended on a method from an static class. I saw we were using [PowerMock][1] and thought to myself: “Well this sounds pretty common, I bet it’s easy to accomplish”. But of course I ran into half a dozen issues before I was able to make it work. Here’s my two cents to make your experience easier than mine.

written in java, mocking, testing Read on →

Keep Trying With Guava Retrying

We were having a [race condition] on a server which was “fixed” by adding an sleep to the thread to check again later. Yes, it sucked, so I decided to make something more sophisticated and went looking for a library to handle retryies with multiple strategies. That’s when I first read about [Guava Retrying]

written in guava, java, libs Read on →

AutoValue for Android

Remember [my last post] on value types using [Google’s AutoValue]? Today while doing some work on a new Android project I’m starting I thought: ‘Great chance to use AutoValue!’. Guess what, there is a port of Google AutoValue for the Android platform.

written in android, java, libs Read on →

Value Types the Easy Way

Value types is a fancy name for those classes where you have to implement equals() and hashCode(), and usually toString(). You’ve probably wrote thounsands of those classes, but have you ever wonder why do you have write almost 50 lines of code to express such a common concept?

written in java, libs Read on →

Guava - Fun With Comparisons

Implementing compare() and compareTo() methods was never fun. Luckily [Guava] provides an utility that makes comparison methods easier to write and more pleasing to the eye.

written in guava, java, libs Read on →