protected void createBundleFile ( HttpServlet servlet , MockServletResponse response , MockServletRequest request , String path , File destFile , String mapping ) throws IOException , ServletException { request . setRequestPath ( mapping , path ) ; // Create the parent directory of the destination file if ( ! destFile . getParentFile ( ) . exists ( ) ) { boolean dirsCreated = destFile . getParentFile ( ) . mkdirs ( ) ; if ( ! dirsCreated ) { throw new IOException ( "The directory '" + destFile . getParentFile ( ) . getCanonicalPath ( ) + "' can't be created." ) ; } } // Set the response mock to write in the destination file try { response . setOutputStream ( new FileOutputStream ( destFile ) ) ; servlet . service ( request , response ) ; } finally { response . close ( ) ; } if ( destFile . length ( ) == 0 ) { logger . warn ( "No content retrieved for file '" + destFile . getAbsolutePath ( ) + "', which is associated to the path : " + path ) ; System . out . println ( "No content retrieved for file '" + destFile . getAbsolutePath ( ) + "', which is associated to the path : " + path ) ; } }
Create the bundle file