< prev index next >

mailinglist/src/test/java/org/openjdk/skara/mailinglist/MboxTests.java

Print this page

159         }
160     }
161 
162     @Test
163     void unencodedFrom() throws IOException {
164         try (var folder = new TemporaryDirectory()) {
165             var rawMbox = folder.path().resolve("test.mbox");
166             Files.writeString(rawMbox,
167                               "From test at example.com  Wed Aug 21 17:22:50 2019\n" +
168                                       "From: test at example.com (test at example.com)\n" +
169                                       "Date: Wed, 21 Aug 2019 17:22:50 +0000\n" +
170                                       "Subject: this is a test\n" +
171                                       "Message-ID: <abc123@example.com>\n" +
172                                       "\n" +
173                                       "Sometimes there are unencoded from lines as well\n" +
174                                       "\n" +
175                                       "From this point onwards, it may be hard to parse this\n" +
176                                       "\n", StandardCharsets.UTF_8);
177             var mbox = MailingListServerFactory.createMboxFileServer(folder.path());
178             var list = mbox.getList("test");
179             var conversations = list.conversations(Duration.ofDays(30));
180             assertEquals(1, conversations.size());
181             var conversation = conversations.get(0);
182             assertEquals(1, conversation.allMessages().size());
183             assertTrue(conversation.first().body().contains("there are unencoded"), conversation.first().body());
184             assertTrue(conversation.first().body().contains("this point onwards"), conversation.first().body());
185         }
186     }
187 }

159         }
160     }
161 
162     @Test
163     void unencodedFrom() throws IOException {
164         try (var folder = new TemporaryDirectory()) {
165             var rawMbox = folder.path().resolve("test.mbox");
166             Files.writeString(rawMbox,
167                               "From test at example.com  Wed Aug 21 17:22:50 2019\n" +
168                                       "From: test at example.com (test at example.com)\n" +
169                                       "Date: Wed, 21 Aug 2019 17:22:50 +0000\n" +
170                                       "Subject: this is a test\n" +
171                                       "Message-ID: <abc123@example.com>\n" +
172                                       "\n" +
173                                       "Sometimes there are unencoded from lines as well\n" +
174                                       "\n" +
175                                       "From this point onwards, it may be hard to parse this\n" +
176                                       "\n", StandardCharsets.UTF_8);
177             var mbox = MailingListServerFactory.createMboxFileServer(folder.path());
178             var list = mbox.getList("test");
179             var conversations = list.conversations(Duration.ofDays(365 * 100));
180             assertEquals(1, conversations.size());
181             var conversation = conversations.get(0);
182             assertEquals(1, conversation.allMessages().size());
183             assertTrue(conversation.first().body().contains("there are unencoded"), conversation.first().body());
184             assertTrue(conversation.first().body().contains("this point onwards"), conversation.first().body());
185         }
186     }
187 }
< prev index next >