Using PODAM - POjo Data Mocker
In each unit testing process, providing various mock objects systematically allows testing diversified cases of software code. In this manner, entity beans or plain old java objects(POJO) can be simply mocked with using PODAM API (developed by Marco Tedone ). This library is comprehensive enough to cover the basics of mocking POJOs and also flexible to develop custom data provider strategies with implementing DataProviderStrategy interface. Metadata constraints such as min-max value of an integer attribute can be created with PODAM annotations that will be evaluated at runtime. In order to start using Podam mock objects, podam-3.0.x.jar and log4j-1.2.x.jar must be added to buildpath of your project. Since, podam-3.0.x is depending on log4j. I used Gallery and Category classes and used the code snippet to generate mock objects. CODE SNIPPET PodamFactory factory = new PodamFactoryImpl(); Gallery gallery = factory.manufacturePojo(Gallery.class); System.out.println(gallery); CO