ATS-35 : T-Engines: update Docker Transformers to Spring Boot 2.0.x GA

- upgraded to Spring boot 2.0.5
   - added dependency to spring-boot-starter-web (before it was brought in by thymeleaf 1.5.15)
   - removed try-catch since UnsupportedEncodingException is not thrown anymore by HierarchicalUriComponents.encodeUriComponent(..)
   - updated WebApplicationConfig to implement WebMvcConfigurer (WebMvcConfigurerAdapter is deprecated)
   - updated import of LocalServerPort
   - updated tests to use new method from InvocationOnMock
This commit is contained in:
DenisGabriela 2018-10-08 14:38:27 +03:00
parent e112d25ee7
commit 24d44398ab
7 changed files with 24 additions and 26 deletions

View File

@ -84,14 +84,14 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
doAnswer((Answer) invocation -> doAnswer((Answer) invocation ->
{ {
File sourceFile = invocation.getArgumentAt(0, File.class); File sourceFile = invocation.getArgument(0);
File targetFile = invocation.getArgumentAt(1, File.class); File targetFile = invocation.getArgument(1);
String actualTargetExtension = StringUtils.getFilenameExtension(targetFile.getAbsolutePath()); String actualTargetExtension = StringUtils.getFilenameExtension(targetFile.getAbsolutePath());
assertNotNull(sourceFile); assertNotNull(sourceFile);
assertNotNull(targetFile); assertNotNull(targetFile);
Long actualTimeout = invocation.getArgumentAt(2, Long.class); Long actualTimeout = invocation.getArgument(2);
assertNotNull(actualTimeout); assertNotNull(actualTimeout);
if (expectedTimeout != null) if (expectedTimeout != null)
{ {

View File

@ -17,6 +17,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@ -719,8 +719,6 @@ public abstract class AbstractTransformerController
} }
protected ResponseEntity<Resource> createAttachment(String targetFilename, File targetFile, Long testDelay) protected ResponseEntity<Resource> createAttachment(String targetFilename, File targetFile, Long testDelay)
{
try
{ {
Resource targetResource = load(targetFile); Resource targetResource = load(targetFile);
targetFilename = UriUtils.encodePath(StringUtils.getFilename(targetFilename), "UTF-8"); targetFilename = UriUtils.encodePath(StringUtils.getFilename(targetFilename), "UTF-8");
@ -732,11 +730,6 @@ public abstract class AbstractTransformerController
getProbeTestTransformInternal().recordTransformTime(time); getProbeTestTransformInternal().recordTransformTime(time);
return body; return body;
} }
catch (UnsupportedEncodingException e)
{
throw new TransformException(500, "Filename encoding error", e);
}
}
/** /**
* Safely converts a {@link String} to an {@link Integer} * Safely converts a {@link String} to an {@link Integer}

View File

@ -28,12 +28,13 @@ package org.alfresco.transformer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.alfresco.transform.client.model.TransformRequestValidator; import org.alfresco.transform.client.model.TransformRequestValidator;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration @Configuration
public class WebApplicationConfig extends WebMvcConfigurerAdapter { public class WebApplicationConfig implements WebMvcConfigurer
{
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {

View File

@ -27,7 +27,7 @@ package org.alfresco.transformer;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;

View File

@ -138,7 +138,7 @@ public abstract class AbstractTransformerControllerTest
{ {
public RuntimeExec.ExecutionResult answer(InvocationOnMock invocation) throws Throwable public RuntimeExec.ExecutionResult answer(InvocationOnMock invocation) throws Throwable
{ {
Map<String, String> actualProperties = invocation.getArgumentAt(0, Map.class); Map<String, String> actualProperties = invocation.getArgument(0);
assertEquals("There should be 3 properties", 3, actualProperties.size()); assertEquals("There should be 3 properties", 3, actualProperties.size());
String actualOptions = actualProperties.get("options"); String actualOptions = actualProperties.get("options");
@ -160,7 +160,7 @@ public abstract class AbstractTransformerControllerTest
assertEquals("expectedOptions", expectedOptions, actualOptions); assertEquals("expectedOptions", expectedOptions, actualOptions);
} }
Long actualTimeout = invocation.getArgumentAt(1, Long.class); Long actualTimeout = invocation.getArgument(1);
assertNotNull(actualTimeout); assertNotNull(actualTimeout);
if (expectedTimeout != null) if (expectedTimeout != null)
{ {

View File

@ -18,7 +18,7 @@
<image.tag>latest</image.tag> <image.tag>latest</image.tag>
<dependency.pdfbox.version>2.0.8</dependency.pdfbox.version> <dependency.pdfbox.version>2.0.8</dependency.pdfbox.version>
<dependency.fabric8.version>3.5.37</dependency.fabric8.version> <dependency.fabric8.version>3.5.37</dependency.fabric8.version>
<dependency.spring-boot.version>1.5.15.RELEASE</dependency.spring-boot.version> <dependency.spring-boot.version>2.0.5.RELEASE</dependency.spring-boot.version>
<dependency.alfresco-core.version>7.3</dependency.alfresco-core.version> <dependency.alfresco-core.version>7.3</dependency.alfresco-core.version>
<dependency.alfresco-data-model.version>8.8</dependency.alfresco-data-model.version> <dependency.alfresco-data-model.version>8.8</dependency.alfresco-data-model.version>
<dependency.alfresco-jodconverter-core.version>3.0.1.1</dependency.alfresco-jodconverter-core.version> <dependency.alfresco-jodconverter-core.version>3.0.1.1</dependency.alfresco-jodconverter-core.version>