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:
@@ -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()+")");
|
||||
|
||||
Reference in New Issue
Block a user