Search in sources :

Example 1 with InputStreamContent

use of org.springframework.extensions.surf.util.InputStreamContent in project alfresco-repository by Alfresco.

the class ScriptNodeTest method testWriteContentWithMimetypeAndWithoutFilename.

/**
 *  https://issues.alfresco.com/jira/browse/MNT-19682
 *  Test that mimetype is correctly set according to the content
 */
@Test
public void testWriteContentWithMimetypeAndWithoutFilename() {
    createTestContent(true);
    ScriptNode scriptNode = new ScriptNode(testNode, SERVICE_REGISTRY);
    scriptNode.setScope(getScope());
    ScriptContentData scd = scriptNode.new ScriptContentData(null, ContentModel.PROP_CONTENT);
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream(TEST_CONTENT_MODEL);
    InputStreamContent inputStreamContent = new InputStreamContent(inputStream, MimetypeMap.MIMETYPE_APPLICATION_PS, "UTF-8");
    scd.write(inputStreamContent, true, false);
    assertEquals(MimetypeMap.MIMETYPE_APPLICATION_PS, scriptNode.getMimetype());
}
Also used : ScriptContentData(org.alfresco.repo.jscript.ScriptNode.ScriptContentData) InputStream(java.io.InputStream) InputStreamContent(org.springframework.extensions.surf.util.InputStreamContent) ActivitiScriptNode(org.alfresco.repo.workflow.activiti.ActivitiScriptNode) Test(org.junit.Test)

Example 2 with InputStreamContent

use of org.springframework.extensions.surf.util.InputStreamContent in project alfresco-repository by Alfresco.

the class ScriptNodeTest method testWriteContentWithMimetypeAndFilename.

/**
 *  https://issues.alfresco.com/jira/browse/MNT-19682
 *  Test that mimetype is correctly set according to the filename
 */
@Test
public void testWriteContentWithMimetypeAndFilename() {
    createTestContent(true);
    ScriptNode scriptNode = new ScriptNode(testNode, SERVICE_REGISTRY);
    scriptNode.setScope(getScope());
    ScriptContentData scd = scriptNode.new ScriptContentData(null, ContentModel.PROP_CONTENT);
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream(TEST_CONTENT_MODEL);
    InputStreamContent inputStreamContent = new InputStreamContent(inputStream, MimetypeMap.MIMETYPE_APPLICATION_PS, "UTF-8");
    scd.write(inputStreamContent, true, false, "test.ai");
    assertEquals(MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, scriptNode.getMimetype());
}
Also used : ScriptContentData(org.alfresco.repo.jscript.ScriptNode.ScriptContentData) InputStream(java.io.InputStream) InputStreamContent(org.springframework.extensions.surf.util.InputStreamContent) ActivitiScriptNode(org.alfresco.repo.workflow.activiti.ActivitiScriptNode) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)2 ScriptContentData (org.alfresco.repo.jscript.ScriptNode.ScriptContentData)2 ActivitiScriptNode (org.alfresco.repo.workflow.activiti.ActivitiScriptNode)2 Test (org.junit.Test)2 InputStreamContent (org.springframework.extensions.surf.util.InputStreamContent)2