This is an automated email from the ASF dual-hosted git repository. jono pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 68ede934e4b CAMEL-20659 include contentTransferEncoding on parsed Disposition Notification Report (#13726) 68ede934e4b is described below commit 68ede934e4b4bd430d7f0795d47e2e3dc6e0bd27 Author: Jono Morris <j...@apache.org> AuthorDate: Wed Apr 10 21:48:20 2024 +1200 CAMEL-20659 include contentTransferEncoding on parsed Disposition Notification Report (#13726) --- .../DispositionNotificationMultipartReportEntity.java | 5 +++-- .../camel/component/as2/api/entity/EntityParser.java | 2 +- .../camel/component/as2/api/entity/EntityParserTest.java | 15 +++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java index cf07c66ea33..d4a227a0e41 100644 --- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java +++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java @@ -31,10 +31,11 @@ import org.apache.hc.core5.http.HttpResponse; public class DispositionNotificationMultipartReportEntity extends MultipartReportEntity { - protected DispositionNotificationMultipartReportEntity(String boundary, boolean isMainBody) { + protected DispositionNotificationMultipartReportEntity(String boundary, String contentTransferEncoding, + boolean isMainBody) { super(ContentType.parse(AS2MimeType.MULTIPART_REPORT + ";" + "report-type=disposition-notification; boundary=\"" + boundary + "\""), - null, isMainBody, boundary); + contentTransferEncoding, isMainBody, boundary); } public DispositionNotificationMultipartReportEntity(ClassicHttpRequest request, diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java index e274b6c21fc..e9c882e8bcf 100644 --- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java +++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java @@ -642,7 +642,7 @@ public final class EntityParser { inbuffer.setCharsetDecoder(charsetDecoder); DispositionNotificationMultipartReportEntity dispositionNotificationMultipartReportEntity - = new DispositionNotificationMultipartReportEntity(boundary, false); + = new DispositionNotificationMultipartReportEntity(boundary, contentTransferEncoding, false); // Skip Preamble and Start Boundary line skipPreambleAndStartBoundary(inbuffer, is, boundary); diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java index 27f2fe44eb7..69a35ca7345 100644 --- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java +++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java @@ -111,7 +111,7 @@ public class EntityParserTest { + "\r\n" + "------=_Part_56_1672293592.1028122454656--\r\n"; - // version of the MDN report without any folded body parts that would be unfolded when the entity is parsed + // version of the Disposition Notification Report without any folded body parts that would be unfolded when the entity is parsed // modifying the report public static final String DISPOSITION_NOTIFICATION_REPORT_CONTENT_UNFOLDED = "\r\n" + "------=_Part_56_1672293592.1028122454656\r\n" @@ -262,7 +262,7 @@ public class EntityParserTest { "Unexpected type for second body part"); } - // verify that parsing the MDN has made no alteration to the entity's body part fields + // verify that parsing the Disposition Notification Report has made no alteration to the entity's body part fields @Test public void messageDispositionNotificationReportBodyContentTest() throws Exception { @@ -270,12 +270,15 @@ public class EntityParserTest { = createMdnEntity(DISPOSITION_NOTIFICATION_REPORT_CONTENT_UNFOLDED, DISPOSITION_NOTIFICATION_REPORT_CONTENT_BOUNDARY); + String expectedContent = String.format("%s\r\n%s\r\n%s", + new BasicHeader(AS2Header.CONTENT_TYPE, REPORT_CONTENT_TYPE_VALUE), + new BasicHeader(AS2Header.CONTENT_TRANSFER_ENCODING, DISPOSITION_NOTIFICATION_REPORT_CONTENT_TRANSFER_ENCODING), + DISPOSITION_NOTIFICATION_REPORT_CONTENT_UNFOLDED); + ByteArrayOutputStream out = new ByteArrayOutputStream(); dispositionNotificationMultipartReportEntity.writeTo(out); - assertEquals(out.toString(DISPOSITION_NOTIFICATION_CONTENT_CHARSET_NAME), - new BasicHeader(AS2Header.CONTENT_TYPE, ContentType.parse(REPORT_CONTENT_TYPE_VALUE)) - + "\r\n" - + DISPOSITION_NOTIFICATION_REPORT_CONTENT_UNFOLDED); + + assertEquals(expectedContent, out.toString(DISPOSITION_NOTIFICATION_CONTENT_CHARSET_NAME)); } @Test