title: Grails integration test and sessionFactory.currentSession
body: <p>Process that loads data from a remote server, triggered by a REST call. The integration test fails with: </p>
  
  <pre><code>java.lang.NullPointerException: Cannot get property 'currentSession' on null object
  </code></pre>
  
  <p>The loads a lot of data, so calls flush every few hundred records loaded:</p>
  
  <pre><code>protected cleanUpGorm() {
      def session = sessionFactory.currentSession
      session.flush()
      session.clear()
  }
  </code></pre>
  
  <p>As noted the session factory is not loaded. This is a 'helper groovy class' - neither service or controller. Do I have to now pass sessionFactory as per GrailsApplication?</p>