mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-12 17:04:48 +00:00
ACS-4739 Fix intermittent tests failures due to CustomTransformers (#747)
This commit is contained in:
parent
bcd1a96a82
commit
e3ac0dcb3b
@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@ -44,6 +44,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.alfresco.transform.base.TransformControllerTest.assertConfig;
|
import static org.alfresco.transform.base.TransformControllerTest.assertConfig;
|
||||||
import static org.alfresco.transform.base.TransformControllerTest.getLogMessagesFor;
|
import static org.alfresco.transform.base.TransformControllerTest.getLogMessagesFor;
|
||||||
@ -63,6 +64,7 @@ import static org.alfresco.transform.common.RequestParamMap.ENDPOINT_VERSION;
|
|||||||
import static org.alfresco.transform.common.RequestParamMap.PAGE_REQUEST_PARAM;
|
import static org.alfresco.transform.common.RequestParamMap.PAGE_REQUEST_PARAM;
|
||||||
import static org.alfresco.transform.common.RequestParamMap.SOURCE_MIMETYPE;
|
import static org.alfresco.transform.common.RequestParamMap.SOURCE_MIMETYPE;
|
||||||
import static org.alfresco.transform.common.RequestParamMap.TARGET_MIMETYPE;
|
import static org.alfresco.transform.common.RequestParamMap.TARGET_MIMETYPE;
|
||||||
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
@ -197,31 +199,34 @@ public class TransformControllerAllInOneTest
|
|||||||
@Test
|
@Test
|
||||||
public void testTransformEndpointUsingTransformEngineWithTwoCustomTransformers() throws Exception
|
public void testTransformEndpointUsingTransformEngineWithTwoCustomTransformers() throws Exception
|
||||||
{
|
{
|
||||||
mockMvc.perform(
|
await()
|
||||||
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
|
.atMost(10, TimeUnit.SECONDS)
|
||||||
.file(new MockMultipartFile("file", null, MIMETYPE_TEXT_PLAIN,
|
.untilAsserted(() -> mockMvc.perform(
|
||||||
"Start".getBytes(StandardCharsets.UTF_8)))
|
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
|
||||||
.param(SOURCE_MIMETYPE, MIMETYPE_TEXT_PLAIN)
|
.file(new MockMultipartFile("file", null, MIMETYPE_TEXT_PLAIN,
|
||||||
.param(TARGET_MIMETYPE, MIMETYPE_PDF)
|
"Start".getBytes(StandardCharsets.UTF_8)))
|
||||||
.param(PAGE_REQUEST_PARAM, "1"))
|
.param(SOURCE_MIMETYPE, MIMETYPE_TEXT_PLAIN)
|
||||||
.andExpect(status().isOk())
|
.param(TARGET_MIMETYPE, MIMETYPE_PDF)
|
||||||
.andExpect(header().string("Content-Disposition",
|
.param(PAGE_REQUEST_PARAM, "1"))
|
||||||
"attachment; filename*=UTF-8''transform.pdf"))
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("Start -> TxT2Pdf(page=1)"));
|
.andExpect(header().string("Content-Disposition",
|
||||||
|
"attachment; filename*=UTF-8''transform.pdf"))
|
||||||
|
.andExpect(content().string("Start -> TxT2Pdf(page=1)")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransformEndpointUsingTransformEngineWithOneCustomTransformer() throws Exception
|
public void testTransformEndpointUsingTransformEngineWithOneCustomTransformer() throws Exception {
|
||||||
{
|
await()
|
||||||
mockMvc.perform(
|
.atMost(10, TimeUnit.SECONDS)
|
||||||
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
|
.untilAsserted(() -> mockMvc.perform(
|
||||||
.file(new MockMultipartFile("file", null, MIMETYPE_PDF,
|
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
|
||||||
"Start".getBytes(StandardCharsets.UTF_8)))
|
.file(new MockMultipartFile("file", null, MIMETYPE_PDF,
|
||||||
.param(SOURCE_MIMETYPE, MIMETYPE_PDF)
|
"Start".getBytes(StandardCharsets.UTF_8)))
|
||||||
.param(TARGET_MIMETYPE, MIMETYPE_IMAGE_JPEG))
|
.param(SOURCE_MIMETYPE, MIMETYPE_PDF)
|
||||||
.andExpect(status().isOk())
|
.param(TARGET_MIMETYPE, MIMETYPE_IMAGE_JPEG))
|
||||||
.andExpect(header().string("Content-Disposition",
|
.andExpect(status().isOk())
|
||||||
"attachment; filename*=UTF-8''transform.jpeg"))
|
.andExpect(header().string("Content-Disposition",
|
||||||
.andExpect(content().string("Start -> Pdf2Jpg()"));
|
"attachment; filename*=UTF-8''transform.jpeg"))
|
||||||
}
|
.andExpect(content().string("Start -> Pdf2Jpg()")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2022 - 2022 Alfresco Software Limited
|
* Copyright (C) 2022 - 2023 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@ -56,14 +56,12 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.alfresco.transform.base.transform.StreamHandlerTest.read;
|
import static org.alfresco.transform.base.transform.StreamHandlerTest.read;
|
||||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_JPEG;
|
import static org.alfresco.transform.common.Mimetype.*;
|
||||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_PDF;
|
import static org.alfresco.transform.common.RequestParamMap.*;
|
||||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.alfresco.transform.common.RequestParamMap.ENDPOINT_TRANSFORM;
|
|
||||||
import static org.alfresco.transform.common.RequestParamMap.SOURCE_MIMETYPE;
|
|
||||||
import static org.alfresco.transform.common.RequestParamMap.TARGET_MIMETYPE;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
@ -148,17 +146,18 @@ public class FragmentHandlerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testErrorIfHttp() throws Exception
|
public void testErrorIfHttp() {
|
||||||
{
|
|
||||||
String expectedError = "Fragments may only be sent via message queues. This an http request";
|
String expectedError = "Fragments may only be sent via message queues. This an http request";
|
||||||
mockMvc.perform(
|
await()
|
||||||
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
|
.atMost(10, TimeUnit.SECONDS)
|
||||||
.file(new MockMultipartFile("file", null, MIMETYPE_TEXT_PLAIN,
|
.untilAsserted(() -> mockMvc.perform(
|
||||||
"Start".getBytes(StandardCharsets.UTF_8)))
|
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
|
||||||
.param(SOURCE_MIMETYPE, MIMETYPE_PDF)
|
.file(new MockMultipartFile("file", null, MIMETYPE_TEXT_PLAIN,
|
||||||
.param(TARGET_MIMETYPE, MIMETYPE_IMAGE_JPEG))
|
"Start".getBytes(StandardCharsets.UTF_8)))
|
||||||
.andExpect(status().isInternalServerError())
|
.param(SOURCE_MIMETYPE, MIMETYPE_PDF)
|
||||||
.andExpect(status().reason(containsString(expectedError)));
|
.param(TARGET_MIMETYPE, MIMETYPE_IMAGE_JPEG))
|
||||||
|
.andExpect(status().isInternalServerError())
|
||||||
|
.andExpect(status().reason(containsString(expectedError))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user