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

@@ -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)
{