When we want to print all the values of an array, the easiest one liner would be to use Arrays.toString(array); e.g String[] a = new String[]{“Sun”,”Moon”}; System.out.println(“Using Arrays –>>>”+Arrays.toString(a)); More to follow … Advertisements

Often most of our classes uses java collections and we tend to expose the collection using java setters and getters. The problems is you can expose more than you need to which can break encapsulation. The getters can allow the clients to change the contents of the collection without knowing the owning class, instead the […]

The easy way to mock chained methods using Mockito is to use RETURN_DEEP_STUBS while mocking. See example below, the multiple steps involved while mocking chained methods. package mock.test; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.when; import org.junit.Test; import org.mockito.Answers; import org.mockito.Mock; public class MockingMethodChains { @Mock private Foo foo; @Mock private Bar bar; @Test public void […]

Couple of days ago, I was faced with the task of creating test suite for Junit 4 and I got a couple of good working examples of the test suite. The exact requirement for me is to come up with a test suite that runs Junit 4 test alone, since our project has also Junit […]

There are many things in the universe beyond earth which requires more understanding, with our current technology the only way to learn more about these strange and¬†mysterious¬†things are Telescopes and Satellites. Traditionally when we think about Telescopes the first things come to our minds are lenses inside a tube, in fact Galileo when he first […]