Skip to content

Commit 24dfcb1

Browse files
CU-85zrnb6u1_PW---631--XML-Handling
1 parent 9364977 commit 24dfcb1

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

iso20022-core/src/main/java/com/prowidesoftware/swift/model/mx/MxParseUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ static Object parseSAXSource(final SAXSource source, final Class targetClass, fi
115115

116116
if(params.charset!=null){
117117
source.getInputSource().setEncoding(params.charset.name());
118+
} else {
119+
source.getInputSource().setEncoding(Charset.defaultCharset().name());
118120
}
119121

120122
JAXBElement element = unmarshaller.unmarshal(source, targetClass);

iso20022-core/src/test/java/com/prowidesoftware/issues/IssueJira631Test.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@
44
import com.prowidesoftware.swift.model.mx.MxPacs00800108;
55
import com.prowidesoftware.swift.model.mx.MxReadParams;
66
import com.prowidesoftware.swift.model.mx.MxWriteConfiguration;
7-
import org.junit.jupiter.api.Disabled;
87
import org.junit.jupiter.api.Test;
9-
import org.junit.jupiter.api.parallel.Execution;
108

11-
import java.io.UnsupportedEncodingException;
129
import java.lang.reflect.Field;
1310
import java.nio.charset.Charset;
1411
import java.nio.charset.StandardCharsets;
1512

1613
import static org.junit.jupiter.api.Assertions.assertFalse;
1714
import static org.junit.jupiter.api.Assertions.assertNotNull;
18-
import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD;
1915

20-
@Disabled
21-
@Execution(SAME_THREAD)
16+
//@Execution(SAME_THREAD)
2217
public class IssueJira631Test {
2318

2419
@Test
@@ -64,7 +59,7 @@ void testBusinessAppHeaderV02() throws IllegalAccessException, NoSuchFieldExcept
6459
System.setProperty("file.encoding", currentCharset);
6560
}
6661

67-
@Test //Single thread
62+
@Test
6863
void testMxPacsWithWindowsEncoding() throws IllegalAccessException, NoSuchFieldException {
6964
String currentCharset = Charset.defaultCharset().name();
7065
Field defaultCharset = Charset.class.getDeclaredField("defaultCharset");
@@ -281,15 +276,16 @@ void testMxPacsWithIBMEncoding() throws IllegalAccessException, NoSuchFieldExcep
281276
MxPacs00800108 parse = MxPacs00800108.parse(xmlAsString);
282277
assertNotNull(parse);
283278

284-
MxWriteConfiguration mxWriteConfiguration = new MxWriteConfiguration();
285-
String modelToStringMsg = parse.message(mxWriteConfiguration);
279+
String modelToStringMsg = parse.message();
280+
System.out.println("Model message with defaultCharset, Cp1141");
286281
System.out.println(modelToStringMsg);
287282
assertFalse(modelToStringMsg.contains("encoding="));
288283

289284
MxPacs00800108 stringToModelMx = MxPacs00800108.parse(modelToStringMsg);
290285
assertNotNull(stringToModelMx);
291286

292287
System.setProperty("file.encoding", currentCharset);
288+
System.out.println("Charset reset from Cp1141 to " + currentCharset);
293289
}
294290

295291
}

0 commit comments

Comments
 (0)