BytesMessage decimal 필드 숫자형 validation 추가 및 단위테스트 작성

- BytesMessage.setDataBytes(): decimal>0 필드에 비숫자 bytes 입력 시
  validation=true이면 MessageSetDataException 발생하도록 수정
- BytesMessageValidationTest: C섹션(C-1/C-2/C-3) 추가,
  tearDown을 clearProperty로 변경하여 SystemKeys 기본값(true) 올바르게 복원,
  B-4 DisplayName/메서드명을 setString이 decimal 검증 경로 밖임을 명시하도록 수정
This commit is contained in:
curry772
2026-05-20 15:08:59 +09:00
parent 858d72c4de
commit 4653d6a50b
2 changed files with 75 additions and 8 deletions
@@ -4,6 +4,7 @@ package com.eactive.eai.transformer.message;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Stack;
@@ -250,6 +251,18 @@ public class BytesMessage extends Message {
item.setValue(ByteUtil.cut(data, startPosition, item.getLength()));
startPosition += item.getLength();
remainSize -= item.getLength();
if (SystemKeys.isValidationEnabled() && item.getDecimalPointLength() > 0) {
String strVal = new String((byte[]) item.getValue(), defaultCharset).trim();
try {
new BigDecimal(strVal);
} catch (NumberFormatException nfe) {
throw new MessageException(
String.format("decimal 필드 숫자형 오류: %s = [%s]",
item.getItemPath(), strVal));
}
}
} catch(MessageException me) {
throw me;
} catch(Exception e) {
StringBuilder sb = new StringBuilder();
sb.append("전문레이아웃 매핑 중 데이터 사이즈 오류 ("+e.getMessage()+")");