Search in sources :

Example 1 with AttachmentManagerService

use of org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService in project carbon-business-process by wso2.

the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAOAddTest.

/**
 * This method tests the attachment upload functionality
 */
public void testAttachmentDAOAddTest() {
    AttachmentManagerService service = new AttachmentManagerService();
    try {
        attachmentID = service.add(createAttachment());
        log.info("Attachment added with id : " + attachmentID);
        assertNotNull(attachmentID);
    } catch (AttachmentMgtException ex) {
        log.error(ex.getLocalizedMessage(), ex);
        Assert.fail("Attachment upload failed due to reason: " + ex.getLocalizedMessage());
    }
}
Also used : AttachmentManagerService(org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService) AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)

Example 2 with AttachmentManagerService

use of org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService in project carbon-business-process by wso2.

the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAORemoveTest.

/**
 * This method tests the attachment removal functionality
 */
public void testAttachmentDAORemoveTest() {
    AttachmentManagerService service = new AttachmentManagerService();
    try {
        if (service.remove(attachmentID)) {
            log.info("Attachment with id: " + attachmentID + " was successfully removed from data-source.");
            assertTrue("Attachment successfully has been removed from data-source.", true);
        } else {
            Assert.fail("Attachment with id: " + attachmentID + " couldn't be removed.");
        }
    } catch (AttachmentMgtException e) {
        log.error(e.getLocalizedMessage(), e);
        Assert.fail("Attachment removal failed due to reason: " + e.getLocalizedMessage());
    }
}
Also used : AttachmentManagerService(org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService) AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)

Example 3 with AttachmentManagerService

use of org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService in project carbon-business-process by wso2.

the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAOGetInfoFromURLTest.

/**
 * This method tests whether it's possible to get the attachment-info for a given attachment url
 */
public void testAttachmentDAOGetInfoFromURLTest() {
    AttachmentManagerService service = new AttachmentManagerService();
    try {
        // Request for the attachment using the attachment id
        TAttachment attachmentFromID = service.getAttachmentInfo(attachmentID);
        // request for the attachment using attachment url
        TAttachment attachmentFromURL = service.getAttachmentInfoFromURL(attachmentFromID.getUrl().toString());
        assertEquals(attachmentFromID.getId(), attachmentFromURL.getId());
        log.info("Attachment information retrieved for uri : " + attachmentFromURL.getUrl().toString());
    } catch (AttachmentMgtException e) {
        log.error(e.getLocalizedMessage(), e);
        Assert.fail("Attachment information retrieval failed due to reason: " + e.getLocalizedMessage());
    }
}
Also used : AttachmentManagerService(org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService) AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException) TAttachment(org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)

Example 4 with AttachmentManagerService

use of org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService in project carbon-business-process by wso2.

the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAOGetInfoTest.

/**
 * This method tests whether it's possible to get the attachment-info for a given attachment id
 */
public void testAttachmentDAOGetInfoTest() {
    AttachmentManagerService service = new AttachmentManagerService();
    try {
        TAttachment attachment = service.getAttachmentInfo(attachmentID);
        dummyAttachment = createAttachment();
        assertEquals(dummyAttachment.getName(), attachment.getName());
        assertEquals(dummyAttachment.getCreatedBy(), attachment.getCreatedBy());
        assertEquals(dummyAttachment.getContentType(), attachment.getContentType());
        log.info("Attachment information retrieved for id : " + attachment.getId());
    } catch (AttachmentMgtException e) {
        log.error(e.getLocalizedMessage(), e);
        Assert.fail("Attachment information retrieval failed due to reason: " + e.getLocalizedMessage());
    }
}
Also used : AttachmentManagerService(org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService) AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException) TAttachment(org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)

Aggregations

AttachmentManagerService (org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)4 TAttachment (org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)2