james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [07/16] james-project git commit: JAMES-2134 Parse Original-Message-ID field and construct appropriate object
Date Thu, 05 Apr 2018 12:51:57 GMT
JAMES-2134 Parse Original-Message-ID field and construct appropriate object


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0cc5bd24
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0cc5bd24
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0cc5bd24

Branch: refs/heads/master
Commit: 0cc5bd2458cbd732dd66167e1f4c30358eb81720
Parents: cd8afdd
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Wed Apr 4 10:50:23 2018 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Thu Apr 5 14:48:42 2018 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/james/mdn/MDNReportParser.java  |  3 ++-
 .../java/org/apache/james/mdn/MDNReportParserTest.java   | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0cc5bd24/mdn/src/main/java/org/apache/james/mdn/MDNReportParser.java
----------------------------------------------------------------------
diff --git a/mdn/src/main/java/org/apache/james/mdn/MDNReportParser.java b/mdn/src/main/java/org/apache/james/mdn/MDNReportParser.java
index a9f8eeb..43d0964 100644
--- a/mdn/src/main/java/org/apache/james/mdn/MDNReportParser.java
+++ b/mdn/src/main/java/org/apache/james/mdn/MDNReportParser.java
@@ -22,6 +22,7 @@ package org.apache.james.mdn;
 import org.apache.james.mdn.fields.AddressType;
 import org.apache.james.mdn.fields.FinalRecipient;
 import org.apache.james.mdn.fields.Gateway;
+import org.apache.james.mdn.fields.OriginalMessageId;
 import org.apache.james.mdn.fields.OriginalRecipient;
 import org.apache.james.mdn.fields.ReportingUserAgent;
 import org.apache.james.mdn.fields.Text;
@@ -511,7 +512,7 @@ public class MDNReportParser {
 
         //    original-message-id-field = "Original-Message-ID" ":" msg-id
         Rule originalMessageIdField() {
-            return Sequence("Original-Message-ID", ":", msgId());
+            return Sequence("Original-Message-ID", ":", msgId(), push(new OriginalMessageId(match())));
         }
 
         //    msg-id          =   [CFWS] "<" id-left "@" id-right ">" [CFWS]

http://git-wip-us.apache.org/repos/asf/james-project/blob/0cc5bd24/mdn/src/test/java/org/apache/james/mdn/MDNReportParserTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/MDNReportParserTest.java b/mdn/src/test/java/org/apache/james/mdn/MDNReportParserTest.java
index c27f280..20cfb30 100644
--- a/mdn/src/test/java/org/apache/james/mdn/MDNReportParserTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/MDNReportParserTest.java
@@ -25,6 +25,7 @@ import org.apache.james.mdn.MDNReportParser.Parser;
 import org.apache.james.mdn.fields.AddressType;
 import org.apache.james.mdn.fields.FinalRecipient;
 import org.apache.james.mdn.fields.Gateway;
+import org.apache.james.mdn.fields.OriginalMessageId;
 import org.apache.james.mdn.fields.OriginalRecipient;
 import org.apache.james.mdn.fields.ReportingUserAgent;
 import org.apache.james.mdn.fields.Text;
@@ -128,4 +129,14 @@ public class MDNReportParserTest {
         assertThat(result.resultValue).isInstanceOf(FinalRecipient.class);
         assertThat((FinalRecipient)result.resultValue).isEqualTo(FinalRecipient.builder().addressType(new
AddressType("rfc822")).finalRecipient(Text.fromRawText("final_recipient")).build());
     }
+
+    @Test
+    public void originalMessageIdShouldParse() {
+        String originalMessageId = "Original-Message-ID: <original@message.id>";
+        Parser parser = Parboiled.createParser(MDNReportParser.Parser.class);
+        ParsingResult<Object> result = new ReportingParseRunner<>(parser.originalMessageIdField()).run(originalMessageId);
+        assertThat(result.matched).isTrue();
+        assertThat(result.resultValue).isInstanceOf(OriginalMessageId.class);
+        assertThat((OriginalMessageId)result.resultValue).isEqualTo(new OriginalMessageId("<original@message.id>"));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message