title: Trouble getting grailsApplication reference from integration test
body: <p>I'm using Grails 1.2.1 and trying to write an integration test for one of my service classes.  The service  method i want to test is ...</p>
  
  <pre><code>class UtilityService {
  
  boolean transactional = false
  
  def grailsApplication
  
  def isAuthorizedHost(String hostIpAddr) {
      // Simple validation
      if (hostIpAddr == null || hostIpAddr.length() == 0)
          return false;
      //
      def allowedDomains = grailsApplication.config.proxy.allowedDomains
  ...
  </code></pre>
  
  <p>but when writing my integration test, I'm unable to get a non-null reference to the grailsApplication object ...</p>
  
  <pre><code>class UtilityServiceTests extends GrailsUnitTestCase {
  
  def grailsApplication
  
  
  void testIsAuthorizedHost() {
      def utilityService = new UtilityService()
      utilityService.grailsApplication = grailsApplication
      def ret = utilityService.isAuthorizedHost("127.0.0.1")
      assertTrue( ret )
  }
  </code></pre>
  
  <p>Here is the error.  How do I get the reference? - Dave</p>
  
  <p>Cannot get property 'config' on null object</p>
  
  <p>java.lang.NullPointerException: Cannot get property 'config' on null object
  at com.nna.tool.proxy.Utility.UtilityService.isAuthorizedHost(UtilityService.groovy:26)
  at com.nna.tool.proxy.Utility.UtilityService$isAuthorizedHost.call(Unknown Source)
  at com.nna.tool.proxy.Utility.UtilityServiceTests.testIsAuthorizedHost(UtilityServiceTests.groovy:20)</p>