TestConfiguration.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:hadoop 作者:
public void testFloatValues() throws IOException {
  out=new BufferedWriter(new FileWriter(CONFIG));
  startConfig();
  appendProperty("test.float1", "3.1415");
  appendProperty("test.float2", "003.1415");
  appendProperty("test.float3", "-3.1415");
  appendProperty("test.float4", " -3.1415 ");
  appendProperty("test.float5", "xyz-3.1415xyz");
  endConfig();
  Path fileResource = new Path(CONFIG);
  conf.addResource(fileResource);
  assertEquals(3.1415f, conf.getFloat("test.float1", 0.0f));
  assertEquals(3.1415f, conf.getFloat("test.float2", 0.0f));
  assertEquals(-3.1415f, conf.getFloat("test.float3", 0.0f));
  assertEquals(-3.1415f, conf.getFloat("test.float4", 0.0f));
  try {
    conf.getFloat("test.float5", 0.0f);
    fail("Property had invalid float value, but was read successfully.");
  } catch (NumberFormatException e) {
    // pass
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号