package org.gluster.test;

import java.io.File;

import junit.framework.Assert;

import org.apache.hadoop.fs.glusterfs.GlusterFUSEInputStream;
import org.apache.hadoop.fs.glusterfs.GlusterFUSEOutputStream;
import org.junit.Before;
import org.junit.Test;

public class TestGlusterFuseInputStream{
	String infile ;

	@Before
	public void create() throws Exception{
		//setup: no need for gluster specific path, since its just reading from local path
	    infile=File.createTempFile("TestGlusterFuseInputStream"+System.currentTimeMillis(),"txt").getAbsolutePath();
		final GlusterFUSEOutputStream stream = new GlusterFUSEOutputStream(infile,true);
		stream.write("hello there, certainly, there is some data in this stream".getBytes());
		stream.close();
	}
	
    @Test
    public void testDoubleClose() throws Exception{
    	 //test
         GlusterFUSEInputStream gfi= new GlusterFUSEInputStream (new File(infile), null, "localhost") ; 
         
         //assert that Position is updated (necessary for hbase to function properly)
         gfi.seek(2);
         Assert.assertEquals(2,gfi.getPos());

         gfi.close();
     
         //cleanup
         new File(infile).delete();
    }
}

@@ -191,32 +191,56 @@
 SEOutputStream;%0A
+import org.junit.After;%0A
 import org.junit
@@ -248,16 +248,16 @@
 Before;%0A
-
 import o
@@ -580,17 +580,58 @@
 ath();%0A%09
-%09
+    new File(infile).deleteOnExit();%0A%09    
 final Gl
@@ -816,10 +816,94 @@
 %0A%09%7D%0A
-
 %09%0A
+%09@After%0A%09public void cleanUp() throws Exception%7B%0A%09    new File(infile).delete();%0A%09%7D%0A
     

delete tmp file on exit, and in cleanup