package uk.ac.ebi.quickgo.common.loader;

import java.io.*;
import java.util.zip.GZIPOutputStream;

/**
 * To test the GZIPFiles class, create a gzip'd file with known test in a temporary location.
 * The client is expected to clean up the file after it's finished with it.
 *
 * @author Tony Wardell
 * Date: 17/05/2016
 * Time: 15:38
 * Created with IntelliJ IDEA.
 */
public class GZIPFileMocker{

    public static final String TEXT = "Mary had a little lamb, it's fleece was white as snow";

    public static final File createTestFile(){

        BufferedWriter bufferedWriter = null;
        File temp = null;
        try {

            temp = File.createTempFile("temp-file-name", "txt.gz");


            //Construct the BufferedWriter object
            bufferedWriter = new BufferedWriter(
                    new OutputStreamWriter(
                            new GZIPOutputStream(new FileOutputStream(temp))
                    ));

            // from the input file to the GZIP output file
            bufferedWriter.write(TEXT);
            bufferedWriter.newLine();


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            //Close the BufferedWrter
            if (bufferedWriter != null) {
                try {
                    bufferedWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        return temp;
    }
}

@@ -91,16 +91,73 @@
 tStream;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0A/**%0A *
@@ -421,23 +421,16 @@
 EA.%0A */%0A
-public 
 class GZ
@@ -445,21 +445,103 @@
 cker
+ 
 %7B
-%0A
 %0A    p
-ublic
+rivate static final Logger logger = LoggerFactory.getLogger(GZIPFileMocker.class);%0A%0A   
  sta
@@ -630,27 +630,14 @@
     
-public static final
+static
  Fil
@@ -654,18 +654,18 @@
 stFile()
+ 
 %7B
-%0A
 %0A       
@@ -721,32 +721,33 @@
 le temp = null;%0A
+%0A
         try %7B%0A%0A 
@@ -810,25 +810,24 @@
 %22txt.gz%22);%0A%0A
-%0A
             
@@ -1196,18 +1196,16 @@
 Line();%0A
-%0A%0A
         
@@ -1217,20 +1217,10 @@
 ch (
-FileNotFound
+IO
 Exce
@@ -1246,93 +1246,33 @@
     
-e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace(
+logger.error(%22Error: %22, e
 );%0A 
@@ -1279,24 +1279,16 @@
        %7D
-%0A       
  finally
@@ -1502,26 +1502,33 @@
     
-e.printStackTrace(
+logger.error(%22Error: %22, e
 );%0A 
@@ -1597,9 +1597,8 @@
 %0A    %7D%0A%7D
-%0A

Use logger to record exception instead of printStackTrace.