ACS-4739 Fix intermittent tests failures due to CustomTransformers (#747)

This commit is contained in:
Domenico Sibilio 2023-03-02 12:22:33 +01:00 committed by GitHub
parent bcd1a96a82
commit e3ac0dcb3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 43 deletions

View File

@ -2,7 +2,7 @@
* #%L
* 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.
* -
@ -44,6 +44,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.concurrent.TimeUnit;
import static org.alfresco.transform.base.TransformControllerTest.assertConfig;
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.SOURCE_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.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@ -197,7 +199,9 @@ public class TransformControllerAllInOneTest
@Test
public void testTransformEndpointUsingTransformEngineWithTwoCustomTransformers() throws Exception
{
mockMvc.perform(
await()
.atMost(10, TimeUnit.SECONDS)
.untilAsserted(() -> mockMvc.perform(
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
.file(new MockMultipartFile("file", null, MIMETYPE_TEXT_PLAIN,
"Start".getBytes(StandardCharsets.UTF_8)))
@ -207,13 +211,14 @@ public class TransformControllerAllInOneTest
.andExpect(status().isOk())
.andExpect(header().string("Content-Disposition",
"attachment; filename*=UTF-8''transform.pdf"))
.andExpect(content().string("Start -> TxT2Pdf(page=1)"));
.andExpect(content().string("Start -> TxT2Pdf(page=1)")));
}
@Test
public void testTransformEndpointUsingTransformEngineWithOneCustomTransformer() throws Exception
{
mockMvc.perform(
public void testTransformEndpointUsingTransformEngineWithOneCustomTransformer() throws Exception {
await()
.atMost(10, TimeUnit.SECONDS)
.untilAsserted(() -> mockMvc.perform(
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
.file(new MockMultipartFile("file", null, MIMETYPE_PDF,
"Start".getBytes(StandardCharsets.UTF_8)))
@ -222,6 +227,6 @@ public class TransformControllerAllInOneTest
.andExpect(status().isOk())
.andExpect(header().string("Content-Disposition",
"attachment; filename*=UTF-8''transform.jpeg"))
.andExpect(content().string("Start -> Pdf2Jpg()"));
.andExpect(content().string("Start -> Pdf2Jpg()")));
}
}

View File

@ -2,7 +2,7 @@
* #%L
* 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.
* -
@ -56,14 +56,12 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
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.MIMETYPE_PDF;
import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
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.alfresco.transform.common.Mimetype.*;
import static org.alfresco.transform.common.RequestParamMap.*;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
@ -148,17 +146,18 @@ public class FragmentHandlerTest
}
@Test
public void testErrorIfHttp() throws Exception
{
public void testErrorIfHttp() {
String expectedError = "Fragments may only be sent via message queues. This an http request";
mockMvc.perform(
await()
.atMost(10, TimeUnit.SECONDS)
.untilAsserted(() -> mockMvc.perform(
MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM)
.file(new MockMultipartFile("file", null, MIMETYPE_TEXT_PLAIN,
"Start".getBytes(StandardCharsets.UTF_8)))
.param(SOURCE_MIMETYPE, MIMETYPE_PDF)
.param(TARGET_MIMETYPE, MIMETYPE_IMAGE_JPEG))
.andExpect(status().isInternalServerError())
.andExpect(status().reason(containsString(expectedError)));
.andExpect(status().reason(containsString(expectedError))));
}
@Test