@Test public void ローテートされたADS書き込み失敗ログが論理削除モードで削除できること() throws AdsWriteFailureLogException { final String fileName = String.format("adsWriteFailure_%s.log.%d", PIO_VERSION_DUMMY, CREATED_TIME_DUMMY); File srcFile = new File("./", fileName); File dstFile = new File("./", fileName + ".done"); RollingAdsWriteFailureLog rolling = new RollingAdsWriteFailureLog(srcFile, null, PIO_VERSION_DUMMY, true); try { if (!srcFile.createNewFile()) { fail("Failed to create temporary file. " + srcFile.getAbsolutePath()); } } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } Boolean isPhysicalDeleteDefault = true; Field isPhysicalDelete = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; isPhysicalDelete = clazz.getDeclaredField("isPhysicalDelete"); isPhysicalDelete.setAccessible(true); isPhysicalDeleteDefault = (Boolean) isPhysicalDelete.get(rolling); isPhysicalDelete.set(rolling, false); rolling.deleteRotatedLog(); assertFalse(srcFile.exists()); assertTrue(dstFile.exists()); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } finally { if (null != srcFile) { srcFile.delete(); } if (null != dstFile) { dstFile.delete(); } if (null != isPhysicalDelete) { try { isPhysicalDelete.set(rolling, isPhysicalDeleteDefault); } catch (Exception e) { e.printStackTrace(); } } } }
public synchronized void deleteRotatedLog() throws AdsWriteFailureLogException { closeRotatedFile(); super.deleteRotatedLog(rotatedAdsWriteFailureLog); }
RollingAdsWriteFailureLog extends AbstractAdsWriteFailureLog { public synchronized void deleteRotatedLog() throws AdsWriteFailureLogException { closeRotatedFile(); super.deleteRotatedLog(rotatedAdsWriteFailureLog); } }
RollingAdsWriteFailureLog extends AbstractAdsWriteFailureLog { public synchronized void deleteRotatedLog() throws AdsWriteFailureLogException { closeRotatedFile(); super.deleteRotatedLog(rotatedAdsWriteFailureLog); } private  RollingAdsWriteFailureLog();  RollingAdsWriteFailureLog(File rotatedAdsWriteFailureLog,
            String baseDir,
            String pcsVersion,
            boolean physicalDelete); }
RollingAdsWriteFailureLog extends AbstractAdsWriteFailureLog { public synchronized void deleteRotatedLog() throws AdsWriteFailureLogException { closeRotatedFile(); super.deleteRotatedLog(rotatedAdsWriteFailureLog); } private  RollingAdsWriteFailureLog();  RollingAdsWriteFailureLog(File rotatedAdsWriteFailureLog,
            String baseDir,
            String pcsVersion,
            boolean physicalDelete); static long getCreatedTimeFromFileName(String pcsVersion, File rotatedAdsWriteFailureLog); void openRotatedFile(); synchronized void closeRotatedFile(); List<String> readAdsFailureLog(int recordNum); synchronized void deleteRotatedLog(); }
RollingAdsWriteFailureLog extends AbstractAdsWriteFailureLog { public synchronized void deleteRotatedLog() throws AdsWriteFailureLogException { closeRotatedFile(); super.deleteRotatedLog(rotatedAdsWriteFailureLog); } private  RollingAdsWriteFailureLog();  RollingAdsWriteFailureLog(File rotatedAdsWriteFailureLog,
            String baseDir,
            String pcsVersion,
            boolean physicalDelete); static long getCreatedTimeFromFileName(String pcsVersion, File rotatedAdsWriteFailureLog); void openRotatedFile(); synchronized void closeRotatedFile(); List<String> readAdsFailureLog(int recordNum); synchronized void deleteRotatedLog();  }