@Test (timeout = 5000)
public void testSetInput() {

  JobConf configuration = new JobConf();
  String[] fieldNames = { "field1", "field2" };
  DBInputFormat.setInput(configuration, NullDBWritable.class, "table",
      "conditions", "orderBy", fieldNames);
  assertEquals(
      "org.apache.hadoop.mapred.lib.db.DBInputFormat$NullDBWritable",
      configuration.getClass(DBConfiguration.INPUT_CLASS_PROPERTY, null)
          .getName());
  assertEquals("table",
      configuration.get(DBConfiguration.INPUT_TABLE_NAME_PROPERTY, null));
  String[] fields = configuration
      .getStrings(DBConfiguration.INPUT_FIELD_NAMES_PROPERTY);
  assertEquals("field1", fields[0]);
  assertEquals("field2", fields[1]);
  assertEquals("conditions",
      configuration.get(DBConfiguration.INPUT_CONDITIONS_PROPERTY, null));
  assertEquals("orderBy",
      configuration.get(DBConfiguration.INPUT_ORDER_BY_PROPERTY, null));
  configuration = new JobConf();
  DBInputFormat.setInput(configuration, NullDBWritable.class, "query",
      "countQuery");
  assertEquals("query", configuration.get(DBConfiguration.INPUT_QUERY, null));
  assertEquals("countQuery",
      configuration.get(DBConfiguration.INPUT_COUNT_QUERY, null));
  
  JobConf jConfiguration = new JobConf();
  DBConfiguration.configureDB(jConfiguration, "driverClass", "dbUrl", "user",
      "password");
  assertEquals("driverClass",
      jConfiguration.get(DBConfiguration.DRIVER_CLASS_PROPERTY));
  assertEquals("dbUrl", jConfiguration.get(DBConfiguration.URL_PROPERTY));
  assertEquals("user", jConfiguration.get(DBConfiguration.USERNAME_PROPERTY));
  assertEquals("password",
      jConfiguration.get(DBConfiguration.PASSWORD_PROPERTY));
  jConfiguration = new JobConf();
  DBConfiguration.configureDB(jConfiguration, "driverClass", "dbUrl");
  assertEquals("driverClass",
      jConfiguration.get(DBConfiguration.DRIVER_CLASS_PROPERTY));
  assertEquals("dbUrl", jConfiguration.get(DBConfiguration.URL_PROPERTY));
  assertNull(jConfiguration.get(DBConfiguration.USERNAME_PROPERTY));
  assertNull(jConfiguration.get(DBConfiguration.PASSWORD_PROPERTY));
}