From b69a17a2a3d7c76ef3344c2fee0bf6c624fae9fb Mon Sep 17 00:00:00 2001 From: David Edwards Date: Thu, 23 Apr 2020 11:05:40 +0100 Subject: [PATCH] ATS-702 Add AIO tests from Misc Transformers (#230) Add Misc transforms AIO tests Add Misc IT through AIO Remove accidental commit. Co-authored-by: Erik Knizat Co-authored-by: kristian Co-authored-by: eknizat <26163420+eknizat@users.noreply.github.com> --- .../alfresco-transform-core-aio-boot/pom.xml | 12 ++- .../AIOControllerImageMagickTest.java | 9 +++ .../transformer/AIOControllerMiscTest.java | 81 +++++++++++++++++++ .../transformer/AIOMiscTransformsIT.java | 40 +++++++++ .../AIOQueueTransformServiceIT.java | 63 +++++++++++++++ .../alfresco-transform-misc-boot/pom.xml | 12 +++ .../transformer/MiscControllerTest.java | 15 ++-- .../test/resources/{quick.txt => quick2.txt} | 0 .../alfresco-transform-tika/pom.xml | 4 - 9 files changed, 222 insertions(+), 14 deletions(-) create mode 100644 alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerMiscTest.java create mode 100644 alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOMiscTransformsIT.java create mode 100644 alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOQueueTransformServiceIT.java rename alfresco-transform-misc/alfresco-transform-misc-boot/src/test/resources/{quick.txt => quick2.txt} (100%) diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml index 65a40435..9c65d341 100644 --- a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml +++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml @@ -38,6 +38,14 @@ test-jar test + + org.alfresco + alfresco-transform-tika-boot + ${project.version} + tests + test-jar + test + org.alfresco alfresco-transform-imagemagick-boot @@ -56,11 +64,11 @@ org.alfresco - alfresco-transform-tika-boot + alfresco-transform-misc-boot + ${project.version} tests test-jar test - ${project.version} org.alfresco diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java index a83347fb..a532951d 100644 --- a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java +++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java @@ -26,6 +26,8 @@ */ package org.alfresco.transformer; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.util.Map; @@ -96,6 +98,13 @@ public class AIOControllerImageMagickTest extends ImageMagickControllerTest return builder; } + @Test + public void testTestValidity() + { + // just test that we are actually testing against the AIOController (instead of MiscController) + assertTrue("Wrong controller wired for test", controller instanceof AIOController); + } + @Test @Override public void noTargetFileTest() diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerMiscTest.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerMiscTest.java new file mode 100644 index 00000000..714f1c60 --- /dev/null +++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerMiscTest.java @@ -0,0 +1,81 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 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 . + * #L% + */ +package org.alfresco.transformer; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.junit4.SpringRunner; + +import static junit.framework.TestCase.assertTrue; + +@RunWith(SpringRunner.class) +@WebMvcTest(AIOController.class) +@Import(AIOCustomConfig.class) +public class AIOControllerMiscTest extends MiscControllerTest +{ + //Tests contained in MiscControllerTest + + + @Test + public void testTestValidity() + { + // just test that we are actually testing against the AIOController (instead of MiscController) + assertTrue("Wrong controller wired for test", controller instanceof AIOController); + } + + @Test + @Override + public void testGetTransformConfigInfo() + { + // Ignore the test in super class as the way the AIO transformer provides config is fundementally different. + + } + + @Test + @Override + public void testGetInfoFromConfigWithDuplicates() + { + // Ignore the test in super class as the way the AIO transformer provides config is fundementally different. + + } + @Test + @Override + public void testGetInfoFromConfigWithEmptyTransformOptions() + { + // Ignore the test in super class as the way the AIO transformer provides config is fundementally different. + + } + @Test + @Override + public void testGetInfoFromConfigWithNoTransformOptions() + { + // Ignore the test in super class as the way the AIO transformer provides config is fundementally different. + + } +} \ No newline at end of file diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOMiscTransformsIT.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOMiscTransformsIT.java new file mode 100644 index 00000000..4f415a6d --- /dev/null +++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOMiscTransformsIT.java @@ -0,0 +1,40 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 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 . + * #L% + */ +package org.alfresco.transformer; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class AIOMiscTransformsIT extends MiscTransformsIT +{ + //Tests are in ImageMagickTransformationIT + public AIOMiscTransformsIT(final SourceTarget sourceTarget) + { + super(sourceTarget); + } +} diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOQueueTransformServiceIT.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOQueueTransformServiceIT.java new file mode 100644 index 00000000..0736dbb9 --- /dev/null +++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOQueueTransformServiceIT.java @@ -0,0 +1,63 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 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 . + * #L% + */ +package org.alfresco.transformer; + +import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML; +import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN; + +import java.util.UUID; + +import org.alfresco.transform.client.model.TransformRequest; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * @author David Edwards + * created on 21/04/2020 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"activemq.url=nio://localhost:61616"}) +public class AIOQueueTransformServiceIT extends AbstractQueueTransformServiceIT +{ + @Override + protected TransformRequest buildRequest() + { + return TransformRequest + .builder() + .withRequestId(UUID.randomUUID().toString()) + .withSourceMediaType(MIMETYPE_HTML) + .withTargetMediaType(MIMETYPE_TEXT_PLAIN) + .withTargetExtension("txt") + .withSchema(1) + .withClientData("ACS") + .withSourceReference(UUID.randomUUID().toString()) + .withSourceSize(32L) + .build(); + } +} \ No newline at end of file diff --git a/alfresco-transform-misc/alfresco-transform-misc-boot/pom.xml b/alfresco-transform-misc/alfresco-transform-misc-boot/pom.xml index 24d745b7..28898441 100644 --- a/alfresco-transform-misc/alfresco-transform-misc-boot/pom.xml +++ b/alfresco-transform-misc/alfresco-transform-misc-boot/pom.xml @@ -86,6 +86,18 @@ org.apache.maven.plugins maven-failsafe-plugin + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + diff --git a/alfresco-transform-misc/alfresco-transform-misc-boot/src/test/java/org/alfresco/transformer/MiscControllerTest.java b/alfresco-transform-misc/alfresco-transform-misc-boot/src/test/java/org/alfresco/transformer/MiscControllerTest.java index 23ca6988..08d7ad90 100644 --- a/alfresco-transform-misc/alfresco-transform-misc-boot/src/test/java/org/alfresco/transformer/MiscControllerTest.java +++ b/alfresco-transform-misc/alfresco-transform-misc-boot/src/test/java/org/alfresco/transformer/MiscControllerTest.java @@ -44,9 +44,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.nio.file.Files; import org.alfresco.transform.client.model.TransformRequest; -import org.alfresco.transformer.transformers.SelectingTransformer; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.text.PDFTextStripper; import org.junit.Before; @@ -54,7 +54,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.annotation.Import; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MvcResult; @@ -65,13 +64,13 @@ import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilde public class MiscControllerTest extends AbstractTransformerControllerTest { @Autowired - private MiscController controller; + protected AbstractTransformerController controller; - private final String sourceEncoding = "UTF-8"; - private final String targetEncoding = "UTF-8"; - private final String targetMimetype = MIMETYPE_TEXT_PLAIN; + protected final String sourceEncoding = "UTF-8"; + protected final String targetEncoding = "UTF-8"; + protected final String targetMimetype = MIMETYPE_TEXT_PLAIN; - private static final String ENGINE_CONFIG_NAME = "misc_engine_config.json"; + protected static final String ENGINE_CONFIG_NAME = "misc_engine_config.json"; @Before public void before() throws Exception @@ -82,7 +81,7 @@ public class MiscControllerTest extends AbstractTransformerControllerTest expectedOptions = null; expectedSourceSuffix = null; expectedSourceFileBytes = readTestFile(sourceExtension); - expectedTargetFileBytes = readTestFile(targetExtension); + expectedTargetFileBytes = Files.readAllBytes(getTestFile("quick2." + targetExtension, true).toPath()); //expectedTargetFileBytes = null; sourceFile = new MockMultipartFile("file", "quick." + sourceExtension, sourceMimetype, expectedSourceFileBytes); diff --git a/alfresco-transform-misc/alfresco-transform-misc-boot/src/test/resources/quick.txt b/alfresco-transform-misc/alfresco-transform-misc-boot/src/test/resources/quick2.txt similarity index 100% rename from alfresco-transform-misc/alfresco-transform-misc-boot/src/test/resources/quick.txt rename to alfresco-transform-misc/alfresco-transform-misc-boot/src/test/resources/quick2.txt diff --git a/alfresco-transform-tika/alfresco-transform-tika/pom.xml b/alfresco-transform-tika/alfresco-transform-tika/pom.xml index a80a58f5..eee57232 100644 --- a/alfresco-transform-tika/alfresco-transform-tika/pom.xml +++ b/alfresco-transform-tika/alfresco-transform-tika/pom.xml @@ -47,10 +47,6 @@ org.quartz-scheduler quartz - - xml-apis - xml-apis -