MetadataStoreModuleFactory { public static MetadataStore getModule() { String metadataStoreClass = null; if (instance == null) { try { Config config = ConfigFactory.load(); if (config.hasPath(METADATA_STORE_CONFIG_KEY)) { metadataStoreClass = config.getString(METADATA_STORE_CONFIG_KEY); LOG.info("Using {} = {}", METADATA_STORE_CONFIG_KEY, metadataStoreClass); } else { metadataStoreClass = MemoryMetadataStore.class.getCanonicalName(); LOG.info("{} is not set, using default {}", METADATA_STORE_CONFIG_KEY, metadataStoreClass); } instance = (MetadataStore) Class.forName(metadataStoreClass).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { LOG.error("Failed to instantiate {}", metadataStoreClass, e); throw new RuntimeException(e.getMessage(), e.getCause()); } } return instance; }  static MetadataStore getModule(); static final String METADATA_STORE_CONFIG_KEY; }
@Test public void testGetModuleWithConf() { System.setProperty("config.resource", "application-test.conf"); MetadataStore instance = MetadataStoreModuleFactory.getModule(); Assert.assertEquals("org.apache.eagle.metadata.persistence.MetadataStoreTest", instance.getName()); }