Save point: [skip ci]

* Remove *HttpRequestTests as they no longer add anthing
This commit is contained in:
alandavis
2022-07-21 14:16:58 +01:00
parent 095a93fc62
commit ef2305eb81
20 changed files with 172 additions and 482 deletions

View File

@@ -1,47 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.aio;
import org.alfresco.transform.base.AbstractHttpRequestTest;
/**
* Tests All-In-One using http and a server test harness.
*/
public class AIOHttpRequestTest extends AbstractHttpRequestTest
{
@Override
protected String getTransformerName()
{
return "0060-AllInOne";
}
@Override
protected String getSourceExtension()
{
return "jpg";
}
}

View File

@@ -39,8 +39,6 @@ import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
* @author David Edwards * @author David Edwards
* created on 21/04/2020 * created on 21/04/2020
*/ */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class AIOQueueTransformServiceIT extends AbstractQueueTransformServiceIT public class AIOQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{ {
@Override @Override

View File

@@ -123,7 +123,7 @@ public class TransformHandler
private Map<String, CustomTransformer> customTransformersByName = new HashMap<>(); private Map<String, CustomTransformer> customTransformersByName = new HashMap<>();
@PostConstruct @PostConstruct
public void init() private void init()
{ {
initTransformEngine(); initTransformEngine();
initProbeTestTransform(); initProbeTestTransform();
@@ -312,7 +312,7 @@ public class TransformHandler
@Override @Override
protected InputStream getInputStream(TransformManagerImpl transformManager) protected InputStream getInputStream(TransformManagerImpl transformManager)
{ {
return getInputStreamFromHttp(requestParameters, sourceMultipartFile, transformManager); return getInputStreamForHandleHttpRequest(requestParameters, sourceMultipartFile, transformManager);
} }
@Override @Override
@@ -348,13 +348,13 @@ public class TransformHandler
transformManager.setSourceFile(sourceFile); transformManager.setSourceFile(sourceFile);
transformManager.setTargetFile(targetFile); transformManager.setTargetFile(targetFile);
transformManager.setSourceFileCreated(); transformManager.setSourceFileCreated();
// we don't want to delete the target file. // We don't want to delete the target file, so don't call setTargetFileCreated()
} }
@Override @Override
protected InputStream getInputStream(TransformManagerImpl transformManager) protected InputStream getInputStream(TransformManagerImpl transformManager)
{ {
return getInputStreamFromProb(sourceFile, transformManager); return getInputStreamForHandleProbRequest(sourceFile, transformManager);
} }
@Override @Override
@@ -389,7 +389,7 @@ public class TransformHandler
@Override @Override
protected InputStream getInputStream(TransformManagerImpl transformManager) protected InputStream getInputStream(TransformManagerImpl transformManager)
{ {
return getInputStreamFromMessage(request, transformManager); return getInputStreamForHandleMessageRequest(request, transformManager);
} }
@Override @Override
@@ -538,8 +538,8 @@ public class TransformHandler
} }
} }
private InputStream getInputStreamFromHttp(Map<String, String> requestParameters, MultipartFile sourceMultipartFile, private InputStream getInputStreamForHandleHttpRequest(Map<String, String> requestParameters,
TransformManagerImpl transformManager) MultipartFile sourceMultipartFile, TransformManagerImpl transformManager)
{ {
final String directUrl = requestParameters.getOrDefault(DIRECT_ACCESS_URL, ""); final String directUrl = requestParameters.getOrDefault(DIRECT_ACCESS_URL, "");
return transformManager.setInputStream(new BufferedInputStream(directUrl.isBlank() ? return transformManager.setInputStream(new BufferedInputStream(directUrl.isBlank() ?
@@ -547,7 +547,7 @@ public class TransformHandler
getDirectAccessUrlInputStream(directUrl))); getDirectAccessUrlInputStream(directUrl)));
} }
private InputStream getInputStreamFromProb(File sourceFile, TransformManagerImpl transformManager) private InputStream getInputStreamForHandleProbRequest(File sourceFile, TransformManagerImpl transformManager)
{ {
try try
{ {
@@ -559,7 +559,8 @@ public class TransformHandler
} }
} }
private InputStream getInputStreamFromMessage(TransformRequest request, TransformManagerImpl transformManager) private InputStream getInputStreamForHandleMessageRequest(TransformRequest request,
TransformManagerImpl transformManager)
{ {
final String directUrl = request.getTransformRequestOptions().getOrDefault(DIRECT_ACCESS_URL, ""); final String directUrl = request.getTransformRequestOptions().getOrDefault(DIRECT_ACCESS_URL, "");
try try

View File

@@ -1,161 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.base;
import static org.alfresco.transform.common.RequestParamMap.DIRECT_ACCESS_URL;
import static org.alfresco.transform.common.RequestParamMap.ENDPOINT_TRANSFORM;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import static org.springframework.test.util.AssertionErrors.assertTrue;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
/**
* Super class with a server test harness, which talks to the TransformController using http.
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes={org.alfresco.transform.base.Application.class})
public abstract class AbstractHttpRequestTest
{
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
protected abstract String getTransformerName();
protected abstract String getSourceExtension();
@Test
public void testPageExists()
{
String result = restTemplate.getForObject("http://localhost:" + port + "/", String.class);
String title = getTransformerName() + " Test Page";
assertTrue("\"" + title + "\" should be part of the page title", result.contains(title));
}
@Test
public void logPageExists()
{
String result = restTemplate.getForObject("http://localhost:" + port + "/log",
String.class);
String title = getTransformerName() + " Log";
assertTrue("\"" + title + "\" should be part of the page title", result.contains(title));
}
@Test
public void errorPageExists()
{
String result = restTemplate.getForObject("http://localhost:" + port + "/error",
String.class);
String title = getTransformerName() + " Error Page";
assertTrue("\"" + title + "\" should be part of the page title", result.contains(title));
}
@Test
public void noFileError()
{
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
parameters.add("targetExtension", ".tmp");
assertTransformError(false, "Required request part 'file' is not present",
parameters);
}
protected void assertTransformError(boolean addFile,
String errorMessage,
LinkedMultiValueMap<String, Object> additionalParams)
{
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
if (addFile)
{
parameters.add("file",
new org.springframework.core.io.ClassPathResource("quick." + getSourceExtension()));
}
if (additionalParams != null)
{
parameters.addAll(additionalParams);
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MULTIPART_FORM_DATA);
HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<>(parameters,
headers);
sendTranformationRequest(entity, errorMessage);
}
@Test
public void httpTransformRequestDirectAccessUrlNotFoundTest()
{
String directUrl = "https://expired/direct/access/url";
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
parameters.add("targetExtension", ".tmp");
parameters.add(DIRECT_ACCESS_URL, directUrl);
assertTransformError(false, "Direct Access Url not found.", parameters);
}
protected void sendTranformationRequest(
final HttpEntity<LinkedMultiValueMap<String, Object>> entity, final String errorMessage)
{
final ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_TRANSFORM, POST, entity,
String.class, "");
assertEquals(errorMessage, getErrorMessage(response.getBody()));
}
// Strip out just the error message from the returned json content body
// Had been expecting the Error page to be returned, but we end up with the json in this test harness.
// Is correct if run manually, so not worrying too much about this.
private String getErrorMessage(String content)
{
String message = "";
int i = content.indexOf("\"message\":\"");
if (i != -1)
{
int j = content.indexOf("\",\"path\":", i);
if (j != -1)
{
message = content.substring(i + 11, j);
}
}
return message;
}
}

View File

@@ -26,12 +26,18 @@
*/ */
package org.alfresco.transform.base; package org.alfresco.transform.base;
import static org.alfresco.transform.messages.TransformStack.PIPELINE_FLAG;
import static org.alfresco.transform.messages.TransformStack.levelBuilder;
import static org.alfresco.transform.messages.TransformStack.setInitialTransformRequestOptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.jms.Queue; import javax.jms.Queue;
import org.alfresco.transform.client.model.InternalContext;
import org.alfresco.transform.client.model.TransformReply; import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest; import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transform.common.ExtensionService;
import org.alfresco.transform.messages.TransformStack;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -42,23 +48,39 @@ import org.springframework.jms.core.JmsTemplate;
* @author Lucian Tuca * @author Lucian Tuca
* created on 15/01/2019 * created on 15/01/2019
*/ */
@SpringBootTest(properties = {"activemq.url=nio://localhost:61616"}) @SpringBootTest(classes={org.alfresco.transform.base.Application.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public abstract class AbstractQueueTransformServiceIT public abstract class AbstractQueueTransformServiceIT
{ {
@Autowired @Autowired
private Queue engineRequestQueue; private Queue engineRequestQueue;
@Autowired @Autowired
private JmsTemplate jmsTemplate; private JmsTemplate jmsTemplate;
private final ActiveMQQueue testingQueue = new ActiveMQQueue("org.alfresco.transform.engine.IT");
private final ActiveMQQueue testingQueue = new ActiveMQQueue(
"org.alfresco.transform.engine.IT");
@Test @Test
public void queueTransformServiceIT() public void queueTransformServiceIT()
{ {
TransformRequest request = buildRequest(); TransformRequest request = buildRequest();
// Router.initialiseContext(TransformRequest)
request.setInternalContext(InternalContext.initialise(request.getInternalContext()));
request.setTargetExtension(ExtensionService.getExtensionForTargetMimetype(request.getTargetMediaType(),
request.getSourceMediaType()));
request.getInternalContext().getMultiStep().setInitialRequestId(request.getRequestId());
request.getInternalContext().getMultiStep().setInitialSourceMediaType(request.getSourceMediaType());
request.getInternalContext().setTransformRequestOptions(request.getTransformRequestOptions());
setInitialTransformRequestOptions(request.getInternalContext(), request.getTransformRequestOptions());
TransformStack.setInitialSourceReference(request.getInternalContext(), request.getSourceReference());
TransformStack.addTransformLevel(request.getInternalContext(), levelBuilder(PIPELINE_FLAG) // pipeline of 1
.withStep(
"transformerName",
request.getSourceMediaType(),
request.getTargetMediaType()));
// TransformStack.setReference(request.getInternalContext(), reference);
jmsTemplate.convertAndSend(engineRequestQueue, request, m -> { jmsTemplate.convertAndSend(engineRequestQueue, request, m -> {
m.setJMSCorrelationID(request.getRequestId()); m.setJMSCorrelationID(request.getRequestId());
m.setJMSReplyTo(testingQueue); m.setJMSReplyTo(testingQueue);

View File

@@ -33,8 +33,7 @@ public class EngineClient
final String engineUrl, final String sourceFile, final String engineUrl, final String sourceFile,
final String sourceMimetype, final String targetMimetype, final String targetExtension) final String sourceMimetype, final String targetMimetype, final String targetExtension)
{ {
return sendTRequest(engineUrl, sourceFile, sourceMimetype, targetMimetype, targetExtension, return sendTRequest(engineUrl, sourceFile, sourceMimetype, targetMimetype, targetExtension, emptyMap());
emptyMap());
} }
public static ResponseEntity<Resource> sendTRequest( public static ResponseEntity<Resource> sendTRequest(

View File

@@ -0,0 +1,113 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.base;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithTwoCustomTransformers;
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Png;
import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
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 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.DIRECT_ACCESS_URL;
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.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
/**
* Super class with a server test harness, which talks to the TransformController using http.
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes={org.alfresco.transform.base.Application.class})
@ContextConfiguration(classes = {
FakeTransformEngineWithTwoCustomTransformers.class,
FakeTransformerTxT2Pdf.class,
FakeTransformerPdf2Png.class})
public class HttpRequestTest
{
@Autowired
private TestRestTemplate restTemplate;
private static final HttpHeaders HEADERS = new HttpHeaders();
static {
HEADERS.setContentType(MULTIPART_FORM_DATA);
}
@Test
public void noFileError()
{
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
parameters.add(SOURCE_MIMETYPE, MIMETYPE_TEXT_PLAIN);
parameters.add(TARGET_MIMETYPE, MIMETYPE_PDF);
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"));
}
@Test
public void httpTransformRequestDirectAccessUrlNotFoundTest()
{
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
parameters.add(DIRECT_ACCESS_URL, "https://expired/direct/access/url");
parameters.add(SOURCE_MIMETYPE, MIMETYPE_TEXT_PLAIN);
parameters.add(TARGET_MIMETYPE, MIMETYPE_PDF);
parameters.add("file", new org.springframework.core.io.ClassPathResource("quick.txt"));
ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_TRANSFORM, POST,
new HttpEntity<>(parameters, HEADERS), String.class, "");
assertTrue(response.getBody().contains("Direct Access Url not found."));
}
@Test
public void transform()
{
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
parameters.add(SOURCE_MIMETYPE, MIMETYPE_TEXT_PLAIN);
parameters.add(TARGET_MIMETYPE, MIMETYPE_PDF);
parameters.add("file", new org.springframework.core.io.ClassPathResource("quick.txt"));
ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_TRANSFORM, POST,
new HttpEntity<>(parameters, HEADERS), String.class, "");
assertEquals("Original Text -> TxT2Pdf()", response.getBody());
}
}

View File

@@ -91,7 +91,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
FakeTransformerPdf2Png.class, FakeTransformerPdf2Png.class,
FakeTransformEngineWithOneCustomTransformer.class, FakeTransformEngineWithOneCustomTransformer.class,
FakeTransformerPdf2Jpg.class}) FakeTransformerPdf2Jpg.class})
public class AllInOneTransformControllerTest public class TransformControllerAllInOneTest
{ {
@Autowired @Autowired
private MockMvc mockMvc; private MockMvc mockMvc;

View File

@@ -85,7 +85,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
/** /**
* Testing base t-engine TransformController functionality. * Testing base t-engine TransformController functionality.
* *
* Also see {@link AllInOneTransformControllerTest}. * Also see {@link TransformControllerAllInOneTest}.
*/ */
@AutoConfigureMockMvc @AutoConfigureMockMvc
@SpringBootTest(classes={org.alfresco.transform.base.Application.class}) @SpringBootTest(classes={org.alfresco.transform.base.Application.class})

View File

@@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited * Copyright (C) 2022 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@@ -24,24 +24,16 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.libreoffice; package org.alfresco.transform.base;
import org.alfresco.transform.base.AbstractHttpRequestTest; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.web.servlet.MockMvc;
/** public class TransformHandlerTest
* Tests LibreOffice using http and a server test harness.
*/
public class LibreOfficeHttpRequestTest extends AbstractHttpRequestTest
{ {
@Override @Autowired
protected String getTransformerName() private MockMvc mockMvc;
{
return "0020-LibreOffice";
}
@Override @Autowired
protected String getSourceExtension() private TransformHandler transformHandler;
{
return "doc";
}
} }

View File

@@ -1,47 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.imagemagick;
import org.alfresco.transform.base.AbstractHttpRequestTest;
/**
* Tests ImageMagick using http and a server test harness.
*/
public class ImageMagickHttpRequestTest extends AbstractHttpRequestTest
{
@Override
protected String getTransformerName()
{
return "0030-ImageMagick";
}
@Override
protected String getSourceExtension()
{
return "jpg";
}
}

View File

@@ -39,8 +39,6 @@ import org.springframework.boot.test.context.SpringBootTest;
* @author Lucian Tuca * @author Lucian Tuca
* created on 15/01/2019 * created on 15/01/2019
*/ */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class ImageMagickQueueTransformServiceIT extends AbstractQueueTransformServiceIT public class ImageMagickQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{ {
@Override @Override

View File

@@ -38,8 +38,6 @@ import org.springframework.boot.test.context.SpringBootTest;
* @author Lucian Tuca * @author Lucian Tuca
* created on 15/01/2019 * created on 15/01/2019
*/ */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class LibreOfficeQueueTransformServiceIT extends AbstractQueueTransformServiceIT public class LibreOfficeQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{ {
@Override @Override

View File

@@ -35,8 +35,6 @@ import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transform.base.AbstractQueueTransformServiceIT; import org.alfresco.transform.base.AbstractQueueTransformServiceIT;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class MiscQueueTransformServiceIT extends AbstractQueueTransformServiceIT public class MiscQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{ {
@Override @Override

View File

@@ -1,47 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.misc;
import org.alfresco.transform.base.AbstractHttpRequestTest;
/**
* Tests Misc using http and a server test harness.
*/
public class MiscTransformerHttpRequestTest extends AbstractHttpRequestTest
{
@Override
protected String getTransformerName()
{
return "0050-Misc";
}
@Override
protected String getSourceExtension()
{
return "html";
}
}

View File

@@ -1,49 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.pdfrenderer;
import org.alfresco.transform.base.AbstractHttpRequestTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
/**
* Tests PdfRenderer using http and a server test harness.
*/
public class AlfrescoPdfRendererHttpRequestTest extends AbstractHttpRequestTest
{
@Override
protected String getTransformerName()
{
return "0040-PdfRenderer";
}
@Override
protected String getSourceExtension()
{
return "pdf";
}
}

View File

@@ -39,8 +39,6 @@ import org.springframework.boot.test.context.SpringBootTest;
* @author Lucian Tuca * @author Lucian Tuca
* created on 15/01/2019 * created on 15/01/2019
*/ */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class AlfrescoPdfRendererQueueTransformServiceIT extends AbstractQueueTransformServiceIT public class AlfrescoPdfRendererQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{ {
@Override @Override

View File

@@ -1,66 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transform.tika;
import org.alfresco.transform.base.AbstractHttpRequestTest;
import org.springframework.util.LinkedMultiValueMap;
/**
* Tests Tika using http and a server test harness.
*/
public class TikaHttpRequestTest extends AbstractHttpRequestTest
{
@Override
protected String getTransformerName()
{
return "0010-Tika";
}
@Override
protected String getSourceExtension()
{
return "pdf";
}
// Override method as Tika requires sourceMimetype
// If not provided then sourceMimetype request parameter error will be thrown.
@Override
protected void assertTransformError(boolean addFile,
String errorMessage,
LinkedMultiValueMap<String, Object> additionalParams)
{
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
parameters.add("sourceMimetype", "application/pdf");
if (additionalParams != null)
{
parameters.addAll(additionalParams);
}
super.assertTransformError(addFile, errorMessage, parameters);
}
}

View File

@@ -39,8 +39,6 @@ import org.springframework.boot.test.context.SpringBootTest;
* @author Lucian Tuca * @author Lucian Tuca
* created on 15/01/2019 * created on 15/01/2019
*/ */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class TikaQueueTransformServiceIT extends AbstractQueueTransformServiceIT public class TikaQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{ {
@Override @Override

View File

@@ -26,33 +26,28 @@
*/ */
package org.alfresco.transform.tika; package org.alfresco.transform.tika;
import static java.text.MessageFormat.format;
import static java.util.function.Function.identity;
import static org.alfresco.transform.base.EngineClient.sendTRequest;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.springframework.http.HttpStatus.OK;
import java.util.Map;
import java.util.stream.Stream;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.alfresco.transform.base.EngineClient; import org.alfresco.transform.base.EngineClient;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import java.util.Map;
import java.util.stream.Stream;
import static java.text.MessageFormat.format;
import static java.util.function.Function.identity;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.springframework.http.HttpStatus.OK;
/** /**
* @author Cezar Leahu * @author Cezar Leahu
*/ */
public class TikaTransformationIT public class TikaTransformationIT
{ {
private static final Logger logger = LoggerFactory.getLogger(TikaTransformationIT.class);
private static final String ENGINE_URL = "http://localhost:8090"; private static final String ENGINE_URL = "http://localhost:8090";
private static final Map<String, String> extensionMimetype = ImmutableMap.of( private static final Map<String, String> extensionMimetype = ImmutableMap.of(
"html", "text/html", "html", "text/html",
@@ -60,8 +55,6 @@ public class TikaTransformationIT
"xhtml", "application/xhtml+xml", "xhtml", "application/xhtml+xml",
"xml", "text/xml"); "xml", "text/xml");
@ParameterizedTest @ParameterizedTest
@MethodSource("engineTransformations") @MethodSource("engineTransformations")
public void testTransformation(Triple<String, String, String> entry) public void testTransformation(Triple<String, String, String> entry)
@@ -77,9 +70,8 @@ public class TikaTransformationIT
} }
else else
{ {
targetMimetype = extensionMimetype.get(entry.getMiddle()); targetMimetype = extensionMimetype.get(targetExtension);
} }
final String descriptor = format("Transform ({0}, {1} -> {2}, {3})", final String descriptor = format("Transform ({0}, {1} -> {2}, {3})",
sourceFile, sourceMimetype, targetMimetype, targetExtension); sourceFile, sourceMimetype, targetMimetype, targetExtension);