コード例 #1
0
 /** Test empty configuration */
 @Test(timeout = 10000)
 public void testEmptyConf() throws Exception {
   HdfsConfiguration conf = new HdfsConfiguration(false);
   // Verify getting addresses fails
   getAddressListFromTool(TestType.NAMENODE, conf, false);
   System.out.println(getAddressListFromTool(TestType.BACKUP, conf, false));
   getAddressListFromTool(TestType.SECONDARY, conf, false);
   getAddressListFromTool(TestType.NNRPCADDRESSES, conf, false);
   for (Command cmd : Command.values()) {
     String arg = cmd.getName();
     CommandHandler handler = Command.getHandler(arg);
     assertNotNull("missing handler: " + cmd, handler);
     if (handler.key != null) {
       // First test with configuration missing the required key
       String[] args = {handler.key};
       runTool(conf, args, false);
     }
   }
 }
コード例 #2
0
 /**
  * Tests commands other than {@link Command#NAMENODE}, {@link Command#BACKUP}, {@link
  * Command#SECONDARY} and {@link Command#NNRPCADDRESSES}
  */
 @Test(timeout = 10000)
 public void testTool() throws Exception {
   HdfsConfiguration conf = new HdfsConfiguration(false);
   for (Command cmd : Command.values()) {
     CommandHandler handler = Command.getHandler(cmd.getName());
     if (handler.key != null && !"-confKey".equals(cmd.getName())) {
       // Add the key to the conf and ensure tool returns the right value
       String[] args = {cmd.getName()};
       conf.set(handler.key, "value");
       assertTrue(runTool(conf, args, true).contains("value"));
     }
   }
 }