mirror of
https://github.com/sismics/docs.git
synced 2025-12-18 20:21:41 +00:00
#177: import document from EML file (wip)
This commit is contained in:
@@ -602,4 +602,29 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertTrue(fileBytes.length > 0); // Images rendered from PDF differ in size from OS to OS due to font issues
|
||||
Assert.assertEquals(MimeType.IMAGE_JPEG, MimeTypeUtil.guessMimeType(fileBytes, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test EML import.
|
||||
*
|
||||
* @throws Exception e
|
||||
*/
|
||||
@Test
|
||||
public void testEmlImport() throws Exception {
|
||||
// Login document_eml
|
||||
clientUtil.createUser("document_eml");
|
||||
String documentEmlToken = clientUtil.login("document_eml");
|
||||
|
||||
// Import a document as EML
|
||||
try (InputStream is = Resources.getResource("file/test_mail.eml").openStream()) {
|
||||
StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("file", is, "test_mail.eml");
|
||||
try (FormDataMultiPart multiPart = new FormDataMultiPart()) {
|
||||
target()
|
||||
.register(MultiPartFeature.class)
|
||||
.path("/document/eml").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, documentEmlToken)
|
||||
.put(Entity.entity(multiPart.bodyPart(streamDataBodyPart),
|
||||
MediaType.MULTIPART_FORM_DATA_TYPE), JsonObject.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9346
docs-web/src/test/resources/file/test_mail.eml
Normal file
9346
docs-web/src/test/resources/file/test_mail.eml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user