package org.axway.grapes.maven;


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 static junit.framework.Assert.*;
import static junit.framework.TestCase.assertFalse;

public class UtilsTest {

    @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());

        Utils.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();
        }

    }
}

@@ -248,68 +248,18 @@
 ork.
-Assert.*;%0Aimport static junit.framework.TestCase.assertFalse
+TestCase.*
 ;%0A%0Ap
@@ -1549,17 +1549,16 @@
 tent);%0A%0A
-%0A
         

Fix wrong imports