ACS-2497 Rework httpTransformRequestUsingDirectAccessUrlTest so it can be used in AI and Aspose (#535)

This commit is contained in:
Alan Davis 2022-02-18 14:08:18 +00:00 committed by GitHub
parent 5587d183f3
commit f05b54dea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -153,6 +153,8 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
{ {
sourceExtension = "pdf"; sourceExtension = "pdf";
targetExtension = "txt"; targetExtension = "txt";
sourceMimetype = MIMETYPE_PDF;
targetMimetype = MIMETYPE_TEXT_PLAIN;
} }
@Override @Override
@ -649,9 +651,6 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
@Override @Override
public void httpTransformRequestUsingDirectAccessUrlTest() throws Exception public void httpTransformRequestUsingDirectAccessUrlTest() throws Exception
{ {
this.sourceExtension = PDF;
this.targetExtension = TXT;
this.sourceMimetype = MIMETYPE_PDF;
expectedTargetFileBytes = readTestFile(targetExtension); expectedTargetFileBytes = readTestFile(targetExtension);
super.httpTransformRequestUsingDirectAccessUrlTest(); super.httpTransformRequestUsingDirectAccessUrlTest();
} }

View File

@ -36,6 +36,7 @@
<div> <div>
<br/> <br/>
<a href="/">Test Transformation</a> <a href="/">Test Transformation</a>
<a href="/transform/config?configVersion=9999">Transformer Config</a>
</div> </div>
</body> </body>

View File

@ -27,6 +27,7 @@
package org.alfresco.transformer; package org.alfresco.transformer;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import static org.alfresco.transform.client.util.RequestParamMap.DIRECT_ACCESS_URL; import static org.alfresco.transform.client.util.RequestParamMap.DIRECT_ACCESS_URL;
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM; import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM_CONFIG_LATEST; import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM_CONFIG_LATEST;
@ -86,6 +87,7 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@ -655,9 +657,15 @@ public abstract class AbstractTransformerControllerTest
File dauSourceFile = getTestFile("quick." + sourceExtension, true); File dauSourceFile = getTestFile("quick." + sourceExtension, true);
String directUrl = "file://" + dauSourceFile.toPath(); String directUrl = "file://" + dauSourceFile.toPath();
mockMvc.perform( ResultActions resultActions = mockMvc.perform(
mockMvcRequest("/transform", null, "targetExtension", targetExtension, DIRECT_ACCESS_URL, directUrl)) mockMvcRequest(ENDPOINT_TRANSFORM, null)
.andExpect(status().is(OK.value())) .param("targetExtension", targetExtension)
.andExpect(content().bytes(expectedTargetFileBytes)); .param(DIRECT_ACCESS_URL, directUrl))
.andExpect(status().is(OK.value()));
if (expectedTargetFileBytes != null)
{
resultActions.andExpect(content().bytes(expectedTargetFileBytes));
}
} }
} }