use of edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl in project cu-kfs by CU-CommunityApps.
the class CuAttachmentServiceImplTest method createAttachment.
@Test
public void createAttachment() throws Exception {
attachmentService.setAntiVirusService(new DummyAntiVirusServiceImpl());
PersistableBusinessObject pbo = setupPersistableBusinessObject();
InputStream inputStream = setupInputStream(ATTACHMENT_TEST_FILE_PATH + File.separator + GOOD_FILE_NAME);
Attachment createdAttachment = attachmentService.createAttachment(pbo, GOOD_FILE_NAME, "txt", 10, inputStream, "txt");
InputStream createdInputStream = new BufferedInputStream(new FileInputStream(buildDocumentDirectory(pbo.getObjectId()) + File.separator + createdAttachment.getAttachmentIdentifier()));
String fileContents = IOUtils.toString(createdInputStream, "UTF-8");
Assert.assertEquals(GOOD_FILE_CONTENTS, fileContents);
Assert.assertEquals(GOOD_FILE_NAME, createdAttachment.getAttachmentFileName());
Assert.assertEquals(10L, createdAttachment.getAttachmentFileSize().longValue());
Assert.assertEquals("txt", createdAttachment.getAttachmentMimeTypeCode());
Assert.assertEquals("txt", createdAttachment.getAttachmentTypeCode());
}
Aggregations