From ccc4a80c9920028a0d6c930dac4f81822fe5fe24 Mon Sep 17 00:00:00 2001 From: Rinjae Date: Mon, 10 Nov 2025 11:23:26 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EB=B0=9C?= =?UTF-8?q?=EC=86=A1=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++ .../com/eactive/ext/kjb/ums/EmailJob.java | 17 +------ .../com/eactive/ext/kjb/ums/test/UmsTest.java | 46 +++++++++++++++---- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 38e9c81..3d53777 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,12 @@ eapim-admin 에서 포함하여 테스트 이용시 느린 부팅 속도 떄문 - EAI 배치 연계 - 고객이메일발송 시스템 연계 +## 테스트 +### testEmailInServer +```bash +# git pull +GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa-jenkins' git pull origin jenkins_with_weblogic + +# test run +KJB_EAPIM_TEST_ENABLED=TRUE kjb-gradle.sh :eapim-admin-kjb:test --tests "com.eactive.ext.kjb.ums.test.UmsTest.testEmailInServer" -Psafedb +``` \ No newline at end of file diff --git a/src/main/java/com/eactive/ext/kjb/ums/EmailJob.java b/src/main/java/com/eactive/ext/kjb/ums/EmailJob.java index c7de34a..dc4d4fe 100644 --- a/src/main/java/com/eactive/ext/kjb/ums/EmailJob.java +++ b/src/main/java/com/eactive/ext/kjb/ums/EmailJob.java @@ -36,7 +36,6 @@ public class EmailJob { private static final int BEFORE_SEND = 2; private static final int SEND = 3; - private final Path tempFilePath; private final Path eaiFilePath; private final Path backupFilePath; private final Path failedFilePath; @@ -52,7 +51,6 @@ public class EmailJob { this.prop = prop; String filename = messageRequest.getServiceId() + "_" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(now); - this.tempFilePath = Paths.get(prop.getUmsEaiBatchSendDir(), filename + ".tmp"); this.eaiFilePath = Paths.get(prop.getUmsEaiBatchSendDir(), filename); this.backupFilePath = Paths.get(prop.getUmsEaiBatchBackupDir(), filename); this.failedFilePath = Paths.get(prop.getUmsEaiBatchBackupDir(), filename + ".failed"); @@ -192,7 +190,7 @@ public class EmailJob { throw new IllegalStateException("Mail File exists for ID: " + messageRequest.getId()); } - File mailFile = tempFilePath.toFile(); + File mailFile = eaiFilePath.toFile(); try { boolean created = mailFile.createNewFile(); if (!created) { @@ -218,22 +216,11 @@ public class EmailJob { throw new RuntimeException(e); } try { - Files.write(tempFilePath, data); - Files.copy(tempFilePath, eaiFilePath); - Files.delete(tempFilePath); + Files.write(eaiFilePath, data); log.debug("Wrote JSON to file: {}", eaiFilePath.toString()); } catch (IOException e) { log.error("Cannot write JSON to file: {}", eaiFilePath.toString(), e); throw new RuntimeException(e); - } finally { - // 임시 파일이 남아 있다면 오류 상황이므로 에러 경로로 이동 - if (Files.exists(tempFilePath)) { - try { - Files.move(tempFilePath, Paths.get(prop.getUmsEaiBatchErrorDir(), tempFilePath.getFileName().toString())); - } catch (IOException e) { - log.warn("임시 파일 저장시 실패 하여 에러 경로로 옮기는 도중 에러 발생", e); - } - } } } diff --git a/src/test/java/com/eactive/ext/kjb/ums/test/UmsTest.java b/src/test/java/com/eactive/ext/kjb/ums/test/UmsTest.java index 4f57a20..ac3a5f3 100644 --- a/src/test/java/com/eactive/ext/kjb/ums/test/UmsTest.java +++ b/src/test/java/com/eactive/ext/kjb/ums/test/UmsTest.java @@ -96,15 +96,43 @@ public class UmsTest { throw new RuntimeException(e); } -// CompletableFuture future = service.sendEmail(messageRequest, (result, ex) -> { -// if (ex != null) { -// log.error("failed", ex); -// } else { -// log.info("result: {}", result); -// } -// }); -// -// future.join(); + log.info("done"); + } + + @Test + public void testEmailInServer() { + Assumptions.assumeTrue( + "true".equalsIgnoreCase(System.getenv("KJB_EAPIM_TEST_ENABLED")), + "OS 환경변수 내 KJB_EAPIM_TEST_ENABLED=TRUE 설정되어 있어야 동작함"); + + prop.setEaiBatchUrl("http://172.31.32.111:10230/BATAppWeb/EaiBatCall"); + prop.setUmsEaiBatchSendDir("/Data/eapim/portal/sendmail/snd"); + prop.setUmsEaiBatchBackupDir("/Data/eapim/portal/sendmail/bak"); + prop.setUmsEaiBatchErrorDir("/Data/eapim/portal/sendmail/ error"); + prop.setUmsEaiBatchInterfaceId("UAGFF00001UIE"); + + + System.getProperties().keySet().forEach(key -> { + log.info("{}: {}", key, System.getProperty((String) key)); + }); + + KjbEmailSendModule service = KjbEmailSendModule.getInstance(prop, null); + MessageRequest messageRequest = new MessageRequest(); + messageRequest.setId(UUID.randomUUID().toString()); + messageRequest.setMessageCode(MessageCode.USER_VERIFICATION_EMAIL); + messageRequest.setEmail("dearmai@dearmai.net"); + messageRequest.setUsername("김광은"); + messageRequest.setSubject("제목 - test"); + messageRequest.setMessage("{\"ATHN_NO\": \"543216\"}"); + messageRequest.setServiceId("FM_APIM001"); + + log.info("MessageRequest - {}", messageRequest); + + try { + service.sendEmail(messageRequest); + } catch (KjbEaiBatchException e) { + throw new RuntimeException(e); + } log.info("done"); }