/*
 * Copyright (c) 2007-2011 by The Broad Institute of MIT and Harvard.  All Rights Reserved.
 *
 * This software is licensed under the terms of the GNU Lesser General Public License (LGPL),
 * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php.
 *
 * THE SOFTWARE IS PROVIDED "AS IS." THE BROAD AND MIT MAKE NO REPRESENTATIONS OR
 * WARRANTES OF ANY KIND CONCERNING THE SOFTWARE, EXPRESS OR IMPLIED, INCLUDING,
 * WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER
 * OR NOT DISCOVERABLE.  IN NO EVENT SHALL THE BROAD OR MIT, OR THEIR RESPECTIVE
 * TRUSTEES, DIRECTORS, OFFICERS, EMPLOYEES, AND AFFILIATES BE LIABLE FOR ANY DAMAGES
 * OF ANY KIND, INCLUDING, WITHOUT LIMITATION, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
 * ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER
 * THE BROAD OR MIT SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT
 * SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING.
 */

package org.broad.igv.tools.parsers;

import org.broad.igv.feature.genome.Genome;
import org.broad.igv.tools.converters.GCTtoIGVConverter;
import org.broad.igv.util.ResourceLocator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

import static org.broad.igv.util.TestUtils.loadGenome;

/**
 * @author jrobinso
 * @date Oct 9, 2010
 */
public class GCTtoIGVConverterTest {

    Genome genome;
    File igvFile;

    @Before
    public void setUp() throws IOException {
        genome = loadGenome("/test/data/genomes/hg18.genome");
        igvFile = null;
    }

    @After
    public void tearDown() throws Exception {
        if (igvFile != null) {
            igvFile.delete();
        }
    }


    @Test
    public void testDescriptionMapping() throws IOException {
        String gctFile = "test/data/gct/igv_test2.gct";
        igvFile = new File("test/data/gct/igv_test2.gct.igv");

        ResourceLocator locator = new ResourceLocator(gctFile);
        GCTtoIGVConverter.convert(locator, igvFile, null, 50000, null, genome);
    }


    @Test
    public void testAffyMapping() throws IOException {
        String gctFile = "test/data/gct/affy_human.gct";
        igvFile = new File("test/data/gct/affy_human.gct.igv");

        ResourceLocator locator = new ResourceLocator(gctFile);
        GCTtoIGVConverter.convert(locator, igvFile, null, 50000, null, genome);
    }

}

@@ -1537,26 +1537,8 @@
 ome;
-%0A    File igvFile;
 %0A%0A  
@@ -1659,32 +1659,8 @@
 %22);%0A
-        igvFile = null;%0A
     
@@ -1723,79 +1723,8 @@
 n %7B%0A
-        if (igvFile != null) %7B%0A            igvFile.delete();%0A        %7D%0A
     
@@ -1855,32 +1855,37 @@
 2.gct%22;%0A        
+File 
 igvFile = new Fi
@@ -1914,32 +1914,64 @@
 test2.gct.igv%22);
+%0A        igvFile.deleteOnExit();
 %0A%0A        Resour
@@ -2234,24 +2234,29 @@
 t%22;%0A        
+File 
 igvFile = ne
@@ -2298,16 +2298,48 @@
 t.igv%22);
+%0A        igvFile.deleteOnExit();
 %0A%0A      

Use deleteOnExit() for temp files instead of manually doing it.