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 ->
{
File sourceFile = invocation.getArgumentAt(0, File.class);
File targetFile = invocation.getArgumentAt(1, File.class);
File sourceFile = invocation.getArgument(0);
File targetFile = invocation.getArgument(1);
String actualTargetExtension = StringUtils.getFilenameExtension(targetFile.getAbsolutePath());
assertNotNull(sourceFile);
assertNotNull(targetFile);
Long actualTimeout = invocation.getArgumentAt(2, Long.class);
Long actualTimeout = invocation.getArgument(2);
assertNotNull(actualTimeout);
if (expectedTimeout != null)
{

View File

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

View File

@ -720,22 +720,15 @@ public abstract class AbstractTransformerController
protected ResponseEntity<Resource> createAttachment(String targetFilename, File targetFile, Long testDelay)
{
try
{
Resource targetResource = load(targetFile);
targetFilename = UriUtils.encodePath(StringUtils.getFilename(targetFilename), "UTF-8");
ResponseEntity<Resource> body = ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename*= UTF-8''" + targetFilename).body(targetResource);
LogEntry.setTargetSize(targetFile.length());
long time = LogEntry.setStatusCodeAndMessage(200, "Success");
time += LogEntry.addDelay(testDelay);
getProbeTestTransformInternal().recordTransformTime(time);
return body;
}
catch (UnsupportedEncodingException e)
{
throw new TransformException(500, "Filename encoding error", e);
}
Resource targetResource = load(targetFile);
targetFilename = UriUtils.encodePath(StringUtils.getFilename(targetFilename), "UTF-8");
ResponseEntity<Resource> body = ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename*= UTF-8''" + targetFilename).body(targetResource);
LogEntry.setTargetSize(targetFile.length());
long time = LogEntry.setStatusCodeAndMessage(200, "Success");
time += LogEntry.addDelay(testDelay);
getProbeTestTransformInternal().recordTransformTime(time);
return body;
}
/**

View File

@ -28,12 +28,13 @@ package org.alfresco.transformer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebApplicationConfig extends WebMvcConfigurerAdapter {
public class WebApplicationConfig implements WebMvcConfigurer
{
@Override
public void addInterceptors(InterceptorRegistry registry) {

View File

@ -27,7 +27,7 @@ package org.alfresco.transformer;
import org.junit.Test;
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.http.*;
import org.springframework.util.LinkedMultiValueMap;

View File

@ -138,7 +138,7 @@ public abstract class AbstractTransformerControllerTest
{
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());
String actualOptions = actualProperties.get("options");
@ -160,7 +160,7 @@ public abstract class AbstractTransformerControllerTest
assertEquals("expectedOptions", expectedOptions, actualOptions);
}
Long actualTimeout = invocation.getArgumentAt(1, Long.class);
Long actualTimeout = invocation.getArgument(1);
assertNotNull(actualTimeout);
if (expectedTimeout != null)
{

View File

@ -18,7 +18,7 @@
<image.tag>latest</image.tag>
<dependency.pdfbox.version>2.0.8</dependency.pdfbox.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-data-model.version>8.8</dependency.alfresco-data-model.version>
<dependency.alfresco-jodconverter-core.version>3.0.1.1</dependency.alfresco-jodconverter-core.version>