Search in sources :

Example 1 with DummyAntiVirusServiceImpl

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());
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Attachment(org.kuali.kfs.krad.bo.Attachment) DummyAntiVirusServiceImpl(edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

DummyAntiVirusServiceImpl (edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1 Attachment (org.kuali.kfs.krad.bo.Attachment)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1