### Question:
OMStorage extends Storage { public static File getOmDbDir(ConfigurationSource conf) { return ServerUtils.getDBPath(conf, OMConfigKeys.OZONE_OM_DB_DIRS); } OMStorage(OzoneConfiguration conf); void setScmId(String scmId); void setOmCertSerialId(String certSerialId); void setOmId(String omId); String getScmId(); String getOmId(); String getOmCertSerialId(); static File getOmDbDir(ConfigurationSource conf); static final String STORAGE_DIR; static final String OM_ID; static final String OM_CERT_SERIAL_ID; }### Answer:
@Test public void testGetOmDbDir() { final File testDir = createTestDir(); final File dbDir = new File(testDir, "omDbDir"); final File metaDir = new File(testDir, "metaDir"); final MutableConfigurationSource conf = new OzoneConfiguration(); conf.set(OMConfigKeys.OZONE_OM_DB_DIRS, dbDir.getPath()); conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, metaDir.getPath()); try { assertEquals(dbDir, OMStorage.getOmDbDir(conf)); assertTrue(dbDir.exists()); } finally { FileUtils.deleteQuietly(dbDir); } }
@Test public void testGetOmDbDirWithFallback() { final File testDir = createTestDir(); final File metaDir = new File(testDir, "metaDir"); final MutableConfigurationSource conf = new OzoneConfiguration(); conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, metaDir.getPath()); try { assertEquals(metaDir, OMStorage.getOmDbDir(conf)); assertTrue(metaDir.exists()); } finally { FileUtils.deleteQuietly(metaDir); } }
@Test public void testNoOmDbDirConfigured() { thrown.expect(IllegalArgumentException.class); OMStorage.getOmDbDir(new OzoneConfiguration()); }