I recently came across a way in Groovy to define a class which can have dynamic getters and setters and properties can be added on the fly. The following code creates a class “MyExpandableClass” and defines two methods in the “getProperty and setProperty”. If we define these two methods in a groovy class, then calls […]
Many a times, it is required to inject a Spring Bean into a Grails artefact. It has happened a few times with us in our projects that we needed to inject a TagLib bean in the service layer for code re-use for sending out e-mails. This is how we achieved it MyService implements org.springframework.context.ApplicationContext Import […]
Just thought I would share with you few tips or key points we should remember while writing integration test cases: 1. Flush and clear the session object for every single test case for example class FooTests extends GroovyTestCase { def sessionFactory void setUp() { sessionFactory.currentSession.flush() sessionFactory.currentSession.clear() } } 2. Drop and create the test database […]
Hi Friends, I was working on the financial application, where the user doesn’t want to select merchant provider while feeding in credit card details and yet we needed to know the merchant provider. Following is the code that helped: function getMerchantProvider(cardNo){ //cardNo is the credit card number var cards = new Array(); cards [0] […]