package org.gluster.test;

import java.io.File;
import java.io.IOException;
import java.util.TreeMap;

import junit.framework.Assert;

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

public class TestGlusterFuseOutputStream {

	@Test
    public void testOutputStream() throws IOException{
      File out = new File("/tmp/testGlusterFuseOutputStream");
      
      //Create a 3 byte FuseOutputStream
      final GlusterFUSEOutputStream stream = new GlusterFUSEOutputStream(out.getAbsolutePath(), true, 3);
      
      stream.write("ab".getBytes());
      
      long sizeBeforeFlush = out.length();
      
      stream.flush();
      stream.close();
      
      //Confirm that the buffer held 100 bytes.
      Assert.assertTrue(out.length() > sizeBeforeFlush);
      out.delete();
    }
}

@@ -502,25 +502,72 @@
 tStream%22
-);%0A      
++System.currentTimeMillis());%0A      out.createNewFile();
 %0A      /
@@ -760,37 +760,71 @@
     
-%0A      long sizeBeforeFlush =
+System.out.println(out.length());%0A%0A      Assert.assertEquals(0,
  out
@@ -832,16 +832,17 @@
 length()
+)
 ;%0A      
@@ -889,24 +889,64 @@
 e();%0A      %0A
+      System.out.println(out.length());%0A
       //Conf
@@ -1004,13 +1004,18 @@
 sert
-True(
+Equals(2, 
 out.
@@ -1026,26 +1026,8 @@
 th()
- %3E sizeBeforeFlush
 );%0A 

update test to exactly confirm 2 bytes post flush