[ACS-10788]: Upgrade Spring Boot in core for ATS upgrade (#1165)

* upgrade spring boot in transform core for ATS

* some test fix

* some test fix

* test fixes

* test fixes attempt

* attempt to fix tests

* attempt to tests fix

* attempt to fix test

* attempt test fix

* attempt to fix test

* attempt to fix tests

* pre commit fix

* QueueTransformServiceTest fix attempt, change mock and added reset of
mock before calling

* TransformRegistryRefreshTest test fix, changed bean injection method and
added license year 2025

* added dependency in transform image magick moduel to fix test

* moved all new dependency in parent pom

* image magick tests fix attempt

* attempt test fix in Tika

* libre office test fix attempt

* LibreOffice tests: Attempt to fix the tests with changing the annotation

* mvn version modularization and license header update for the modified file

* attempt to fix E2E tests

* remove duplicate maven dependency

* attempt to fix unstable AIO tests

* pre commit fix

* remove redundant annotations and refactor dependencies

* fix for flaky AIO tests

* attempt to fix the AIO flaky tests

* remove duplicate maven dependency

* removed redundant maven dependencies

* update version for next alpha release

* incorporate PR comments

* add spring-boot-restclient to fix missing RestTemplateBuilder and add aspectJ new dependency

* remove lenient for sharedFileStoreClient in TikaTest file

* Incorporate PR comments
This commit is contained in:
Vivek Kumar
2026-02-03 15:23:02 +05:30
committed by GitHub
parent 33bbc6c2c6
commit b6d522ee9b
29 changed files with 173 additions and 101 deletions
@@ -78,6 +78,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -36,7 +36,8 @@ import static org.alfresco.transform.common.RequestParamMap.ENDPOINT_TRANSFORM;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.resttestclient.TestRestTemplate;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -49,6 +50,7 @@ import org.springframework.util.LinkedMultiValueMap;
* Super class for testing controllers with a server. Includes tests for the AbstractTransformerController itself. Note: Currently uses json rather than HTML as json is returned by this spring boot test harness.
*/
@Deprecated
@AutoConfigureTestRestTemplate
public abstract class AbstractHttpRequestTest
{
@LocalServerPort
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -67,13 +67,13 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.client.model.InternalContext;
@@ -107,10 +107,10 @@ public abstract class AbstractTransformerControllerTest
@Autowired
protected ObjectMapper objectMapper;
@MockBean
@MockitoBean
protected AlfrescoSharedFileStoreClient alfrescoSharedFileStoreClient;
@SpyBean
@MockitoSpyBean
protected TransformServiceRegistry transformRegistry;
@Value("${transform.core.version}")
@@ -222,7 +222,7 @@ public abstract class AbstractTransformerControllerTest
return testFileUrl == null ? null : testFile;
}
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
if (sourceFile == null)
{
@@ -234,10 +234,10 @@ public abstract class AbstractTransformerControllerTest
}
}
private MockHttpServletRequestBuilder mockMvcRequestWithoutMockMultipartFile(String url,
private MockMultipartHttpServletRequestBuilder mockMvcRequestWithoutMockMultipartFile(String url,
String... params)
{
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM);
MockMultipartHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM);
if (params.length % 2 != 0)
{
@@ -251,10 +251,10 @@ public abstract class AbstractTransformerControllerTest
return builder;
}
private MockHttpServletRequestBuilder mockMvcRequestWithMockMultipartFile(String url, MockMultipartFile sourceFile,
private MockMultipartHttpServletRequestBuilder mockMvcRequestWithMockMultipartFile(String url, MockMultipartFile sourceFile,
String... params)
{
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM).file(
MockMultipartHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM).file(
sourceFile);
if (params.length % 2 != 0)
+5
View File
@@ -137,6 +137,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.alfresco.transform.base.AbstractBaseTest;
import org.alfresco.transform.base.TransformController;
@@ -73,7 +73,7 @@ public class AIOTest extends AbstractBaseTest
@Override
// Add extra required parameters to the request.
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
return super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
+18 -1
View File
@@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<artifactId>spring-boot-starter-aspectj</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -49,6 +49,7 @@
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>${spring-retry.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
@@ -112,6 +113,22 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-jackson2</artifactId>
</dependency>
<!-- Changes to pom.xml with Spring Boot 4.0 -->
<!-- The required test dependencies is modularized -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-restclient</artifactId>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -29,8 +29,8 @@ package org.alfresco.transform.base;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.micrometer.metrics.autoconfigure.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -142,8 +142,11 @@ public class SharedFileStoreClient
{
logger.debug(" Deleting intermediate file {}", fileReference);
client.delete().uri(fileReference)
.exchange().block();
client.delete()
.uri(fileReference)
.retrieve()
.toBodilessEntity()
.block();
}
catch (Exception e)
{
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -58,17 +58,17 @@ import java.util.concurrent.atomic.AtomicLong;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.util.ReflectionTestUtils;
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.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.base.executors.CommandExecutor;
@@ -86,6 +86,7 @@ import org.alfresco.transform.registry.TransformServiceRegistry;
* Super class for unit testing.
*/
@SpringBootTest(classes = {org.alfresco.transform.base.Application.class})
@ExtendWith(org.mockito.junit.jupiter.MockitoExtension.class)
@AutoConfigureMockMvc
public abstract class AbstractBaseTest
{
@@ -105,10 +106,10 @@ public abstract class AbstractBaseTest
@Autowired
protected ObjectMapper objectMapper;
@MockBean
@MockitoBean
protected SharedFileStoreClient sharedFileStoreClient;
@SpyBean
@Autowired
protected TransformServiceRegistry transformRegistry;
protected String sourceExtension;
@@ -227,7 +228,7 @@ public abstract class AbstractBaseTest
return testFileUrl == null ? null : testFile;
}
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
if (sourceFile == null)
{
@@ -239,9 +240,9 @@ public abstract class AbstractBaseTest
}
}
private MockHttpServletRequestBuilder mockMvcRequestWithoutMockMultipartFile(String url, String... params)
private MockMultipartHttpServletRequestBuilder mockMvcRequestWithoutMockMultipartFile(String url, String... params)
{
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(url);
MockMultipartHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(url);
if (params.length % 2 != 0)
{
@@ -255,10 +256,10 @@ public abstract class AbstractBaseTest
return builder;
}
private MockHttpServletRequestBuilder mockMvcRequestWithMockMultipartFile(String url, MockMultipartFile sourceFile,
private MockMultipartHttpServletRequestBuilder mockMvcRequestWithMockMultipartFile(String url, MockMultipartFile sourceFile,
String... params)
{
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM).file(sourceFile);
MockMultipartHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(url).file(sourceFile);
if (params.length % 2 != 0)
{
@@ -330,6 +331,7 @@ public abstract class AbstractBaseTest
@Test
public void noExtensionSourceFilenameTest() throws Exception
{
options.clear();
sourceFile = new MockMultipartFile("file", "../quick", sourceMimetype, sourceFileBytes);
mockMvc.perform(
@@ -59,8 +59,8 @@ import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
@@ -85,14 +85,14 @@ import org.junit.jupiter.api.io.TempDir;
import org.mockito.stubbing.Answer;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -132,7 +132,7 @@ public class TransformControllerTest
private String coreVersion;
@TempDir
public File tempDir;
@MockBean
@MockitoBean
protected SharedFileStoreClient fakeSfsClient;
static void resetProbeForTesting(TransformController transformController)
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -40,13 +40,15 @@ import static org.alfresco.transform.common.RequestParamMap.TARGET_MIMETYPE;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.resttestclient.TestRestTemplate;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.util.HtmlUtils;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithTwoCustomTransformers;
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Png;
@@ -61,6 +63,7 @@ import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
FakeTransformEngineWithTwoCustomTransformers.class,
FakeTransformerTxT2Pdf.class,
FakeTransformerPdf2Png.class})
@AutoConfigureTestRestTemplate
public class RestTest
{
@Autowired
@@ -82,7 +85,7 @@ public class RestTest
ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_TRANSFORM, POST,
new HttpEntity<>(parameters, HEADERS), String.class, "");
assertTrue(response.getBody().contains("Required request part 'file' is not present"));
assertTrue(HtmlUtils.htmlUnescape(response.getBody()).contains("Required request part 'file' is not present"));
}
@Test
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -44,23 +44,27 @@ import jakarta.jms.Message;
import org.apache.activemq.command.ActiveMQObjectMessage;
import org.apache.activemq.command.ActiveMQQueue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.alfresco.transform.base.TransformController;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;
@SpringBootTest(classes = {org.alfresco.transform.base.Application.class})
@ExtendWith(MockitoExtension.class)
public class QueueTransformServiceTest
{
@Mock
@MockitoBean
private TransformController transformController;
@Mock
@MockitoBean
private TransformMessageConverter transformMessageConverter;
@Mock
@MockitoBean
private TransformReplySender transformReplySender;
@InjectMocks
@@ -143,6 +147,7 @@ public class QueueTransformServiceTest
public void testConvertMessageThrowsJMSExceptionThenReplyWithInternalServerError()
throws JMSException
{
Mockito.reset(transformController);
ActiveMQObjectMessage msg = new ActiveMQObjectMessage();
msg.setCorrelationId("1234");
ActiveMQQueue destination = new ActiveMQQueue();
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 Alfresco Software, Ltd. All rights reserved.
* Copyright 2015-2026 Alfresco Software, Ltd. All rights reserved.
*
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
@@ -16,9 +16,8 @@ import com.google.common.collect.ImmutableMap;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.util.ReflectionTestUtils;
@@ -36,7 +35,7 @@ import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class TransformRegistryRefreshTest
{
@SpyBean(proxyTargetAware = false)
@Autowired
private TransformRegistry transformRegistry;
@Autowired
private TransformConfigFromFiles transformConfigFromFiles;
@@ -44,8 +44,8 @@ import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.test.util.ReflectionTestUtils;
import org.alfresco.transform.base.fakes.AbstractFakeTransformEngine;
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2022 - 2023 Alfresco Software Limited
* Copyright (C) 2022 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -51,15 +51,15 @@ import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -85,11 +85,11 @@ public class FragmentHandlerTest
@Autowired
private MockMvc mockMvc;
@MockBean
@MockitoBean
protected SharedFileStoreClient fakeSfsClient;
@MockBean
@MockitoBean
private TransformReplySender transformReplySender;
@MockBean
@MockitoBean
private ProbeTransform probeTransform;
private void assertFragments(String sourceText, String expectedError, List<String> expectedLines)
+5
View File
@@ -58,6 +58,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -60,16 +60,17 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.base.AbstractBaseTest;
@@ -84,6 +85,7 @@ import org.alfresco.transform.imagemagick.transformers.ImageMagickCommandExecuto
/**
* Test ImageMagick with mocked external command.
*/
@AutoConfigureMockMvc
public class ImageMagickTest extends AbstractBaseTest
{
private static String PREFIX_IMAGE = "image/";
@@ -91,11 +93,11 @@ public class ImageMagickTest extends AbstractBaseTest
@Autowired
private ImageMagickCommandExecutor imageMagickCommandExecutor;
@Mock
@MockitoBean
protected ExecutionResult mockExecutionResult;
@Mock
@MockitoBean
protected RuntimeExec mockTransformCommand;
@Mock
@MockitoBean
protected RuntimeExec mockCheckCommand;
@Value("${transform.core.imagemagick.exe}")
protected String EXE;
@@ -122,9 +124,9 @@ public class ImageMagickTest extends AbstractBaseTest
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
final MockMultipartHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
+5
View File
@@ -62,6 +62,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -59,17 +59,18 @@ import org.artofsolving.jodconverter.office.OfficeException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Spy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.base.AbstractBaseTest;
@@ -84,18 +85,19 @@ import org.alfresco.transform.libreoffice.transformers.LibreOfficeTransformer;
/**
* Test LibreOffice with mocked external command.
*/
@AutoConfigureMockMvc
public class LibreOfficeTest extends AbstractBaseTest
{
protected static String targetMimetype = MIMETYPE_PDF;
@Autowired
@MockitoSpyBean
private LibreOfficeTransformer libreOfficeTransformer;
@Autowired
private CustomTransformers customTransformers;
@Spy
@Autowired
private LibreOfficeTransformer spyLibreOfficeTransformer;
@Mock
@MockitoBean
protected ExecutionResult mockExecutionResult;
@Value("${transform.core.libreoffice.path}")
@@ -162,9 +164,9 @@ public class LibreOfficeTest extends AbstractBaseTest
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
final MockMultipartHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
+5
View File
@@ -102,6 +102,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -57,7 +57,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.alfresco.transform.base.AbstractBaseTest;
@@ -84,9 +84,9 @@ public class MiscTest extends AbstractBaseTest
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
final MockMultipartHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("sourceEncoding", sourceEncoding)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype)
@@ -451,7 +451,7 @@ public class MiscTest extends AbstractBaseTest
final MockMultipartFile sourceFile = new MockMultipartFile("file",
"test_file." + sourceExtension, sourceMimetype, content);
final MockHttpServletRequestBuilder requestBuilder = super.mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile)
final MockMultipartHttpServletRequestBuilder requestBuilder = super.mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile)
.param(TARGET_MIMETYPE, targetMimetype)
.param(SOURCE_MIMETYPE, sourceMimetype);
+5
View File
@@ -54,6 +54,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -59,7 +59,6 @@ import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -68,7 +67,8 @@ import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.base.AbstractBaseTest;
@@ -87,11 +87,11 @@ public class PdfRendererTest extends AbstractBaseTest
{
@Autowired
private PdfRendererTransformer pdfRendererTransformer;
@Mock
@MockitoBean
private ExecutionResult mockExecutionResult;
@Mock
@MockitoBean
protected RuntimeExec mockTransformCommand;
@Mock
@MockitoBean
protected RuntimeExec mockCheckCommand;
@Value("${transform.core.pdfrenderer.exe}")
protected String execPath;
@@ -110,9 +110,9 @@ public class PdfRendererTest extends AbstractBaseTest
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
final MockMultipartHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
+5
View File
@@ -119,6 +119,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -29,6 +29,7 @@ package org.alfresco.transform.tika;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.when;
import static org.springframework.http.HttpHeaders.ACCEPT;
import static org.springframework.http.HttpHeaders.CONTENT_DISPOSITION;
@@ -97,7 +98,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.base.AbstractBaseTest;
@@ -156,9 +157,9 @@ public class TikaTest extends AbstractBaseTest
expectedTargetFileBytes = readTargetFileBytes ? readTestFile(targetExtension) : null;
sourceFile = new MockMultipartFile("file", "quick." + sourceExtension, sourceMimetype, sourceFileBytes);
when(mockExecutionResult.getExitValue()).thenReturn(0);
when(mockExecutionResult.getStdErr()).thenReturn("STDERROR");
when(mockExecutionResult.getStdOut()).thenReturn("STDOUT");
lenient().when(mockExecutionResult.getExitValue()).thenReturn(0);
lenient().when(mockExecutionResult.getStdErr()).thenReturn("STDERROR");
lenient().when(mockExecutionResult.getStdOut()).thenReturn("STDOUT");
}
private void transform(String transform, String sourceExtension, String targetExtension,
@@ -170,7 +171,7 @@ public class TikaTest extends AbstractBaseTest
this.targetMimetype = targetMimetype;
System.out.println("Test " + transform + " " + sourceExtension + " to " + targetExtension);
MockHttpServletRequestBuilder requestBuilder = includeContents == null
MockMultipartHttpServletRequestBuilder requestBuilder = includeContents == null
? mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
"targetExtension", this.targetExtension)
: mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
@@ -187,7 +188,7 @@ public class TikaTest extends AbstractBaseTest
@Override
// Add extra required parameters to the request.
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
protected MockMultipartHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile, String... params)
{
return super.mockMvcRequest(url, sourceFile, params)
.param("targetEncoding", targetEncoding)
@@ -384,7 +385,7 @@ public class TikaTest extends AbstractBaseTest
"\"{http://www.alfresco.org/model/content/1.0}description\":[\"desc1\",\"desc2\"]," +
"\"{http://www.alfresco.org/model/content/1.0}created\":\"created1\"}";
MockHttpServletRequestBuilder requestBuilder = super.mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
MockMultipartHttpServletRequestBuilder requestBuilder = super.mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
"targetExtension", XLSX,
"metadata", metadata,
"targetMimetype", MIMETYPE_METADATA_EMBED,
@@ -450,7 +451,7 @@ public class TikaTest extends AbstractBaseTest
when(sharedFileStoreClient.retrieveFile(sourceFileRef)).thenReturn(response);
when(sharedFileStoreClient.saveFile(any()))
.thenReturn(new FileRefResponse(new FileRefEntity(targetFileRef)));
when(mockExecutionResult.getExitValue()).thenReturn(0);
lenient().when(mockExecutionResult.getExitValue()).thenReturn(0);
// Update the Transformation Request with any specific params before sending it
updateTransformRequestWithSpecificOptions(transformRequest);
@@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2026 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@@ -198,7 +198,7 @@ public class TikaTransformationIT
assertThat(expectedException).as(description)
.hasMessageContaining(TransformerMessages.CORRUPTED_FILE_ERROR)
.extracting(HttpClientErrorException::getStatusCode)
.isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
.isEqualTo(HttpStatus.UNPROCESSABLE_CONTENT);
}
private static Stream<Triple<String, String, String>> engineTransformationsCorruptedToText()
+2 -1
View File
@@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.7</version>
<version>4.0.2</version>
</parent>
<properties>
@@ -35,6 +35,7 @@
<parent.core.deploy.skip>false</parent.core.deploy.skip>
<commons-lang3.version>3.18.0</commons-lang3.version>
<spring-retry.version>2.0.12</spring-retry.version>
</properties>
<profiles>