@Test @Ignore public void オープン済みのADS書き込み失敗ログファイルのOutputStreamが存在しない場合に再オープンでエラーとなること() { try { writer.openActiveFile(); } catch (AdsWriteFailureLogException e) { fail("open failure test failed"); } File file = null; try { Class<?> clazz = writer.getClass(); Field ostream = clazz.getDeclaredField("activeFileOutputStream"); ostream.setAccessible(true); ostream.set(writer, null); file = getAdsWriteFailureLog(); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } try { writer.openActiveFile(); fail("open failure test failed"); } catch (AdsWriteFailureLogException e) { assertTrue(file.exists()); } finally { if (null != file) { file.delete(); } } }
public synchronized void openActiveFile() throws AdsWriteFailureLogException { File file = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); if (null != activeFileOutputStream) { String message = String.format("Acitve adsWriteFailureLog is already opened. [%s]", file.getAbsolutePath()); logger.info(message); return; } synchronized (this) { if (file.isFile()) { String message = String.format("Active adsWriteFailureLog already exists, but is not opened. [%s]", file.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message); } File newFile = null; try { createdTime = System.currentTimeMillis(); newFile = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); activeFileOutputStream = new FileOutputStream(newFile, true); } catch (FileNotFoundException e) { String message = String.format("Failed to open acitve adsWriteFailureLog. [%s]", newFile.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message, e); } } }
AdsWriteFailureLogWriter extends AbstractAdsWriteFailureLog { public synchronized void openActiveFile() throws AdsWriteFailureLogException { File file = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); if (null != activeFileOutputStream) { String message = String.format("Acitve adsWriteFailureLog is already opened. [%s]", file.getAbsolutePath()); logger.info(message); return; } synchronized (this) { if (file.isFile()) { String message = String.format("Active adsWriteFailureLog already exists, but is not opened. [%s]", file.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message); } File newFile = null; try { createdTime = System.currentTimeMillis(); newFile = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); activeFileOutputStream = new FileOutputStream(newFile, true); } catch (FileNotFoundException e) { String message = String.format("Failed to open acitve adsWriteFailureLog. [%s]", newFile.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message, e); } } } }
AdsWriteFailureLogWriter extends AbstractAdsWriteFailureLog { public synchronized void openActiveFile() throws AdsWriteFailureLogException { File file = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); if (null != activeFileOutputStream) { String message = String.format("Acitve adsWriteFailureLog is already opened. [%s]", file.getAbsolutePath()); logger.info(message); return; } synchronized (this) { if (file.isFile()) { String message = String.format("Active adsWriteFailureLog already exists, but is not opened. [%s]", file.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message); } File newFile = null; try { createdTime = System.currentTimeMillis(); newFile = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); activeFileOutputStream = new FileOutputStream(newFile, true); } catch (FileNotFoundException e) { String message = String.format("Failed to open acitve adsWriteFailureLog. [%s]", newFile.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message, e); } } } private  AdsWriteFailureLogWriter(); }
AdsWriteFailureLogWriter extends AbstractAdsWriteFailureLog { public synchronized void openActiveFile() throws AdsWriteFailureLogException { File file = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); if (null != activeFileOutputStream) { String message = String.format("Acitve adsWriteFailureLog is already opened. [%s]", file.getAbsolutePath()); logger.info(message); return; } synchronized (this) { if (file.isFile()) { String message = String.format("Active adsWriteFailureLog already exists, but is not opened. [%s]", file.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message); } File newFile = null; try { createdTime = System.currentTimeMillis(); newFile = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); activeFileOutputStream = new FileOutputStream(newFile, true); } catch (FileNotFoundException e) { String message = String.format("Failed to open acitve adsWriteFailureLog. [%s]", newFile.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message, e); } } } private  AdsWriteFailureLogWriter(); static synchronized AdsWriteFailureLogWriter getInstance(
            String baseDir, String pcsVersion, boolean physicalDelete); static synchronized AdsWriteFailureLogWriter getInstanceforRetry(
            String baseDir, String pcsVersion, boolean physicalDelete); static synchronized AdsWriteFailureLogWriter getInstanceforError(
            String baseDir, String pcsVersion, boolean physicalDelete); synchronized void openActiveFile(); synchronized void openActiveFile(long timeStamp); synchronized void closeActiveFile(); synchronized void writeActiveFile(AdsWriteFailureLogInfo output); synchronized void writeActiveFile(String output); synchronized File rotateActiveFile(); synchronized void deleteActiveLog(); boolean isExistsAdsWriteFailureLogs(); }
AdsWriteFailureLogWriter extends AbstractAdsWriteFailureLog { public synchronized void openActiveFile() throws AdsWriteFailureLogException { File file = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); if (null != activeFileOutputStream) { String message = String.format("Acitve adsWriteFailureLog is already opened. [%s]", file.getAbsolutePath()); logger.info(message); return; } synchronized (this) { if (file.isFile()) { String message = String.format("Active adsWriteFailureLog already exists, but is not opened. [%s]", file.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message); } File newFile = null; try { createdTime = System.currentTimeMillis(); newFile = new File(getBaseDir(), String.format(LOGNAME_FORMAT_ACTIVE, getPcsVersion(), createdTime)); activeFileOutputStream = new FileOutputStream(newFile, true); } catch (FileNotFoundException e) { String message = String.format("Failed to open acitve adsWriteFailureLog. [%s]", newFile.getAbsolutePath()); resetFilelds(); throw new AdsWriteFailureLogException(message, e); } } } private  AdsWriteFailureLogWriter(); static synchronized AdsWriteFailureLogWriter getInstance(
            String baseDir, String pcsVersion, boolean physicalDelete); static synchronized AdsWriteFailureLogWriter getInstanceforRetry(
            String baseDir, String pcsVersion, boolean physicalDelete); static synchronized AdsWriteFailureLogWriter getInstanceforError(
            String baseDir, String pcsVersion, boolean physicalDelete); synchronized void openActiveFile(); synchronized void openActiveFile(long timeStamp); synchronized void closeActiveFile(); synchronized void writeActiveFile(AdsWriteFailureLogInfo output); synchronized void writeActiveFile(String output); synchronized File rotateActiveFile(); synchronized void deleteActiveLog(); boolean isExistsAdsWriteFailureLogs();  }