@Test public void testLoadBak() throws Exception { ConfigManager testConfigManager = buildTestConfigManager(); File file = createAndWriteFile(testConfigManager.configFilePath() + ".bak"); Method declaredMethod = ConfigManager.class.getDeclaredMethod("loadBak"); declaredMethod.setAccessible(true); Boolean loadBakResult = (Boolean) declaredMethod.invoke(testConfigManager); assertTrue(loadBakResult); file.delete(); Boolean loadBakResult2 = (Boolean) declaredMethod.invoke(testConfigManager); assertTrue(loadBakResult2); declaredMethod.setAccessible(false); }
private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; }
ConfigManager { private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; } }
ConfigManager { private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; }  }
ConfigManager { private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; }  abstract String encode(); boolean load(); abstract String configFilePath(); abstract void decode(final String jsonString); synchronized void persist(); abstract String encode(final boolean prettyFormat); }
ConfigManager { private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; }  abstract String encode(); boolean load(); abstract String configFilePath(); abstract void decode(final String jsonString); synchronized void persist(); abstract String encode(final boolean prettyFormat);  }