grails - Trouble getting grailsApplication reference from integration test -


I'm using Grails 1.2.1 and trying to write integration tests for one of my service classes I am Care system I want to test myself ...

  class utilityservice {boolean transactional = false def grailsApplication def isAuthorizedHost (string hostIpAddr) {// simple verification that (hostIpAddr == null || hostIpAddr. Length () == 0) return false; // were allowed def = grailsApplication.config.proxy.allowedDomains ...   

But the type I integration testing time, I am unable to get a non-null reference to grailsApplication object Am ..

  Class UtilityServiceTests extends GrailsUnitTestCase {def zero grailsApplication testIsAuthorizedHost () {def utilityService = new utilityService () utilityService.grailsApplication = grailsApplication Def retired = utilityService.isAuthorizedHost ("127.0.0.1") assertTrue (Ret }}   

Here is the error How do I get the references? - Dave

Property 'config' can not get on the null object

java.lang.NullPointerException: on com.nna.tool.proxy.Utility property 'config' null object Download can not .UtilityService.isAuthorizedHost (UtilityService.groovy: 26) on com.nna.tool.proxy.Utility.UtilityService $ isAuthorizedHost.call (unknown source) at com.nna.tool.proxy.Utility.UtilityServiceTests.testIsAuthorizedHost ( UtilityServiceTests.groovy: 20)

here's the answer. It can also work in your situation. You can put that setup in Setup Setup () method ...



Comments