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{
	final String infile = "/mnt/glusterfs/testGFIStream";

	@Before
	public void create() throws Exception{
		//setup
		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();
    }
}

@@ -290,22 +290,16 @@
 tream%7B%0A%09
-final 
 String i
@@ -308,40 +308,8 @@
 ile 
-= %22/mnt/glusterfs/testGFIStream%22
 ;%0A%0A%09
@@ -365,16 +365,205 @@
 %09//setup
+: no need for gluster specific path, since its just reading from local path%0A%09    infile=File.createTempFile(%22TestGlusterFuseInputStream%22+System.currentTimeMillis(),%22txt%22).getAbsolutePath();
 %0A%09%09final
@@ -748,11 +748,8 @@
 ();%0A
-%09%09%0A
 %09%7D%0A%09

remove dependence on /mnt/glusterfs and GlusterFileSystem from path