当前位置: 首页>>代码示例>>Java>>正文


Java FormatUtils类代码示例

本文整理汇总了Java中alluxio.util.FormatUtils的典型用法代码示例。如果您正苦于以下问题:Java FormatUtils类的具体用法?Java FormatUtils怎么用?Java FormatUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormatUtils类属于alluxio.util包,在下文中一共展示了FormatUtils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: lsTest

import alluxio.util.FormatUtils; //导入依赖的package包/类
@Test
public void lsTest() throws IOException, AlluxioException {
  URIStatus[] files = new URIStatus[3];

  FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA",
          WriteType.MUST_CACHE, 10, 10);
  FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB",
          WriteType.MUST_CACHE, 20, 20);
  FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC",
          WriteType.THROUGH, 30, 30);

  files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA"));
  files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir"));
  files[2] = fs.getStatus(new AlluxioURI("/testRoot/testFileC"));

  InterpreterResult output = alluxioInterpreter.interpret("ls /testRoot", null);

  String expected = "";
  String format = "%-10s%-25s%-15s%-5s\n";
  expected += String.format(format, FormatUtils.getSizeFromBytes(10),
          CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In Memory", "/testRoot/testFileA");
  expected += String.format(format, FormatUtils.getSizeFromBytes(0),
          CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "", "/testRoot/testDir");
  expected += String.format(format, FormatUtils.getSizeFromBytes(30),
          CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "Not In Memory",
          "/testRoot/testFileC");
  expected += "\n";

  Assert.assertEquals(Code.SUCCESS, output.code());
  Assert.assertEquals(expected, output.message().get(0).getData());
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:AlluxioInterpreterTest.java

示例2: lsRecursiveTest

import alluxio.util.FormatUtils; //导入依赖的package包/类
@Test
public void lsRecursiveTest() throws IOException, AlluxioException {
  URIStatus[] files = new URIStatus[4];

  FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA",
          WriteType.MUST_CACHE, 10, 10);
  FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB",
          WriteType.MUST_CACHE, 20, 20);
  FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC",
          WriteType.THROUGH, 30, 30);

  files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA"));
  files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir"));
  files[2] = fs.getStatus(new AlluxioURI("/testRoot/testDir/testFileB"));
  files[3] = fs.getStatus(new AlluxioURI("/testRoot/testFileC"));

  InterpreterResult output = alluxioInterpreter.interpret("ls -R /testRoot", null);

  String expected = "";
  String format = "%-10s%-25s%-15s%-5s\n";
  expected +=
          String.format(format, FormatUtils.getSizeFromBytes(10),
                  CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In Memory",
                  "/testRoot/testFileA");
  expected +=
          String.format(format, FormatUtils.getSizeFromBytes(0),
                  CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "", "/testRoot/testDir");
  expected +=
          String.format(format, FormatUtils.getSizeFromBytes(20),
                  CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "In Memory",
                  "/testRoot/testDir/testFileB");
  expected +=
          String.format(format, FormatUtils.getSizeFromBytes(30),
                  CommandUtils.convertMsToDate(files[3].getCreationTimeMs()), "Not In Memory",
                  "/testRoot/testFileC");
  expected += "\n";

  Assert.assertEquals(expected, output.message().get(0).getData());
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:40,代码来源:AlluxioInterpreterTest.java


注:本文中的alluxio.util.FormatUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。