package org.axway.grapes.maven.utils;


import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;

import static junit.framework.Assert.assertEquals;
import static junit.framework.TestCase.*;

public class FileUtilsTest {

    @Test
    public void checkSerialization() throws MojoExecutionException {
        final File testdir = new File(System.getProperty("user.dir") + "/target");
        final String content = "content";
        final String fileName = "test.txt";

        final File testFile = new File(testdir, fileName);
        assertFalse(testFile.exists());

        FileUtils.serialize(testdir, content, fileName);
        assertTrue(testFile.exists());

        FileReader reader = null;
        BufferedReader buff = null;
        String realContent = null;

        try{
            reader = new FileReader(testFile);
            buff = new BufferedReader(reader);

            realContent = buff.readLine();

        }
        catch (Exception e){

        }
        finally {
            if(buff != null){
                try {
                    buff.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(reader != null){
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        assertNotNull(realContent);
        assertEquals(content, realContent);

        if(testFile.exists()){
            testFile.delete();
        }

    }


}

@@ -33,16 +33,49 @@
 tils;%0A%0A%0A
+import junit.framework.TestCase;%0A
 import o
@@ -278,59 +278,8 @@
 L;%0A%0A
-import static junit.framework.Assert.assertEquals;%0A
 impo
@@ -1697,11 +1697,348 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void checkReadMethod() throws MojoExecutionException %7B%0A        final URL testFile = Thread.currentThread().getContextClassLoader().getResource(%22org/axway/grapes/maven/utils/file.txt%22);%0A%0A        assertNotNull(testFile);%0A        assertEquals(%22Can you read this?%22, FileUtils.read(new File(testFile.getPath())));%0A    %7D%0A%0A
 %0A%7D%0A

Add missing test case