// Path: giraffa-core/src/test/java/org/apache/giraffa/GiraffaTestUtils.java
// public static void printFileStatus(FileStatus fileStat) throws IOException {
//   printFileStatus(fileStat, -1);
// }


import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.EnumSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.CreateFlag;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
import org.apache.hadoop.io.IOUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.apache.giraffa.GiraffaTestUtils.printFileStatus;
import static org.apache.hadoop.fs.CreateFlag.APPEND;
import static org.apache.hadoop.fs.CreateFlag.CREATE;
import static org.apache.hadoop.fs.CreateFlag.OVERWRITE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
    GiraffaFileSystem.format(conf, false);
    grfs = (GiraffaFileSystem) FileSystem.get(conf);
    path = new Path("newlyCreatedFile.txt");
    permission = new FsPermission((short)0666);
    bufferSize = 4096;
    replication = 3;
    blockSize = 512;
  }

  @After
  public void after() throws IOException {
    IOUtils.cleanup(LOG, grfs);
  }

  @AfterClass
  public static void afterClass() throws Exception {
    UTIL.shutdownMiniCluster();
  }

  /**
   * Tests for different CreateFlag combinations
   */
  @Test
  public void testCanCreateNewFileWithCreateFlagOnly()
          throws IOException {
    EnumSet<CreateFlag> flags = EnumSet.of(CREATE);
    grfs.create(path, permission, flags, bufferSize, replication,
            blockSize, null);
    FileStatus[] files = grfs.listStatus(new Path("."));
    LOG.debug("list files under home dir");
// Path: giraffa-core/src/test/java/org/apache/giraffa/GiraffaTestUtils.java
// public static void printFileStatus(FileStatus fileStat) throws IOException {
//   printFileStatus(fileStat, -1);
// }


// Path: giraffa-core/src/test/java/org/apache/giraffa/TestCreate.java
import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.EnumSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.CreateFlag;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
import org.apache.hadoop.io.IOUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.apache.giraffa.GiraffaTestUtils.printFileStatus;
import static org.apache.hadoop.fs.CreateFlag.APPEND;
import static org.apache.hadoop.fs.CreateFlag.CREATE;
import static org.apache.hadoop.fs.CreateFlag.OVERWRITE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

    GiraffaFileSystem.format(conf, false);
    grfs = (GiraffaFileSystem) FileSystem.get(conf);
    path = new Path("newlyCreatedFile.txt");
    permission = new FsPermission((short)0666);
    bufferSize = 4096;
    replication = 3;
    blockSize = 512;
  }

  @After
  public void after() throws IOException {
    IOUtils.cleanup(LOG, grfs);
  }

  @AfterClass
  public static void afterClass() throws Exception {
    UTIL.shutdownMiniCluster();
  }

  /**
   * Tests for different CreateFlag combinations
   */
  @Test
  public void testCanCreateNewFileWithCreateFlagOnly()
          throws IOException {
    EnumSet<CreateFlag> flags = EnumSet.of(CREATE);
    grfs.create(path, permission, flags, bufferSize, replication,
            blockSize, null);
    FileStatus[] files = grfs.listStatus(new Path("."));
    LOG.debug("list files under home dir");
    printFileStatus(files);