mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
Upgraded junit 4.13.2 tests to 5.2.8 as they were not being run
This commit is contained in:
@@ -23,14 +23,14 @@ package org.alfresco.transform.messages;
|
|||||||
|
|
||||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_PNG;
|
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_PNG;
|
||||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_PDF;
|
import static org.alfresco.transform.common.Mimetype.MIMETYPE_PDF;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.alfresco.transform.client.model.TransformRequest;
|
import org.alfresco.transform.client.model.TransformRequest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.validation.DirectFieldBindingResult;
|
import org.springframework.validation.DirectFieldBindingResult;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
|
|
||||||
|
@@ -25,25 +25,22 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.alfresco.transform.common.TransformConfigResourceReader;
|
|
||||||
import org.alfresco.transform.config.SupportedSourceAndTarget;
|
import org.alfresco.transform.config.SupportedSourceAndTarget;
|
||||||
import org.alfresco.transform.config.TransformConfig;
|
import org.alfresco.transform.config.TransformConfig;
|
||||||
import org.alfresco.transform.config.TransformStep;
|
import org.alfresco.transform.config.TransformStep;
|
||||||
import org.alfresco.transform.config.Transformer;
|
import org.alfresco.transform.config.Transformer;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the CombinedTransformConfig, extended by both T-Router and ACS repository.
|
* Test the CombinedTransformConfig, extended by both T-Router and ACS repository.
|
||||||
@@ -258,7 +255,7 @@ public class CombinedTransformConfigTest
|
|||||||
assertEquals(numberOfTEngineTransformers, transformConfig.getTransformers().size());
|
assertEquals(numberOfTEngineTransformers, transformConfig.getTransformers().size());
|
||||||
Transformer actualTransformer = transformConfig.getTransformers().get(numberOfTEngineTransformers - 1);
|
Transformer actualTransformer = transformConfig.getTransformers().get(numberOfTEngineTransformers - 1);
|
||||||
assertEquals(expectedTransformer, actualTransformer);
|
assertEquals(expectedTransformer, actualTransformer);
|
||||||
assertSame("It should even == the expected transform", expectedTransformer, actualTransformer);
|
assertTrue(expectedTransformer == actualTransformer);
|
||||||
|
|
||||||
// Check the baseUrl is that of the original t-engine that will do the work, if the overriding transform
|
// Check the baseUrl is that of the original t-engine that will do the work, if the overriding transform
|
||||||
// is a single step transform.
|
// is a single step transform.
|
||||||
@@ -385,8 +382,8 @@ public class CombinedTransformConfigTest
|
|||||||
config.combineTransformerConfig(registry);
|
config.combineTransformerConfig(registry);
|
||||||
|
|
||||||
String expected = "Transformer \"1\" references \"unknown\" which do not exist. Read from readFromB";
|
String expected = "Transformer \"1\" references \"unknown\" which do not exist. Read from readFromB";
|
||||||
assertEquals(1, registry.errorMessages.size());
|
assertEquals(1, registry.warnMessages.size());
|
||||||
assertEquals(expected, registry.errorMessages.get(0));
|
assertEquals(expected, registry.warnMessages.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -30,13 +30,13 @@ import org.alfresco.transform.config.RemoveSupported;
|
|||||||
import org.alfresco.transform.config.SupportedSourceAndTarget;
|
import org.alfresco.transform.config.SupportedSourceAndTarget;
|
||||||
import org.alfresco.transform.config.TransformConfig;
|
import org.alfresco.transform.config.TransformConfig;
|
||||||
import org.alfresco.transform.config.Transformer;
|
import org.alfresco.transform.config.Transformer;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the json elements: {@code removeTransformers}, {@code addSupported}, {@code removeSupported},
|
* Tests the json elements: {@code removeTransformers}, {@code addSupported}, {@code removeSupported},
|
||||||
@@ -455,6 +455,6 @@ public class OverrideTransformConfigTests
|
|||||||
Set<SupportedSourceAndTarget> supportedSourceAndTargetList = resultConfig.getTransformers().get(0).getSupportedSourceAndTargetList();
|
Set<SupportedSourceAndTarget> supportedSourceAndTargetList = resultConfig.getTransformers().get(0).getSupportedSourceAndTargetList();
|
||||||
assertTrue(supportedSourceAndTargetList.equals(expectedSupported));
|
assertTrue(supportedSourceAndTargetList.equals(expectedSupported));
|
||||||
|
|
||||||
assertEquals("toString() difference", expectedToString, supportedSourceAndTargetList.toString());
|
assertEquals(expectedToString, supportedSourceAndTargetList.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,15 +27,16 @@
|
|||||||
package org.alfresco.transform.registry;
|
package org.alfresco.transform.registry;
|
||||||
|
|
||||||
import org.alfresco.transform.common.TransformException;
|
import org.alfresco.transform.common.TransformException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
import static org.alfresco.transform.registry.TransformRegistryHelper.retrieveTransformListBySize;
|
import static org.alfresco.transform.registry.TransformRegistryHelper.retrieveTransformListBySize;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class TransformRegistryHelperTest
|
public class TransformRegistryHelperTest
|
||||||
{
|
{
|
||||||
@@ -118,10 +119,10 @@ public class TransformRegistryHelperTest
|
|||||||
|
|
||||||
private void assertOrder(List<SupportedTransform> transformsInLoadOrder, List<SupportedTransform> expectedList)
|
private void assertOrder(List<SupportedTransform> transformsInLoadOrder, List<SupportedTransform> expectedList)
|
||||||
{
|
{
|
||||||
TransformRegistryHelper helper = new TransformRegistryHelper();
|
AtomicInteger transformerCount = new AtomicInteger(0);
|
||||||
TransformCache data = new TransformCache();
|
TransformCache data = new TransformCache();
|
||||||
transformsInLoadOrder.forEach(t->data.appendTransform("text/plain", "application/pdf", t,
|
transformsInLoadOrder.forEach(t->data.appendTransform("text/plain", "application/pdf", t,
|
||||||
null, null));
|
"transformer"+transformerCount.getAndIncrement(), null));
|
||||||
|
|
||||||
List<SupportedTransform> supportedTransforms = retrieveTransformListBySize(data,
|
List<SupportedTransform> supportedTransforms = retrieveTransformListBySize(data,
|
||||||
"text/plain", "application/pdf", null, null);
|
"text/plain", "application/pdf", null, null);
|
||||||
@@ -132,8 +133,8 @@ public class TransformRegistryHelperTest
|
|||||||
String expectedTransformerName = expectedList.get(0).getName();
|
String expectedTransformerName = expectedList.get(0).getName();
|
||||||
long expectedMaxSourceSizeBytes = findMaxSize(expectedList);
|
long expectedMaxSourceSizeBytes = findMaxSize(expectedList);
|
||||||
assertEquals(expectedList, supportedTransforms);
|
assertEquals(expectedList, supportedTransforms);
|
||||||
assertEquals("Transform name", expectedTransformerName, transformerName);
|
assertEquals(expectedTransformerName, transformerName);
|
||||||
assertEquals("MaxSize", expectedMaxSourceSizeBytes, maxSize);
|
assertEquals(expectedMaxSourceSizeBytes, maxSize);
|
||||||
|
|
||||||
// If the above two pass, we don't really need the following one, but if it is wrong it might indicate
|
// If the above two pass, we don't really need the following one, but if it is wrong it might indicate
|
||||||
// something is wrong, where the sourceSizeInBytes is not just 1.
|
// something is wrong, where the sourceSizeInBytes is not just 1.
|
||||||
@@ -159,23 +160,25 @@ public class TransformRegistryHelperTest
|
|||||||
supportedTransforms.get(supportedTransforms.size() - 1).getMaxSourceSizeBytes();
|
supportedTransforms.get(supportedTransforms.size() - 1).getMaxSourceSizeBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TransformException.class)
|
@Test
|
||||||
public void buildTransformListSourceMimeTypeNullErrorTest()
|
public void buildTransformListSourceMimeTypeNullErrorTest()
|
||||||
{
|
{
|
||||||
TransformCache data = new TransformCache();
|
TransformCache data = new TransformCache();
|
||||||
|
|
||||||
retrieveTransformListBySize(data, null, "application/pdf", null, null);
|
assertThrows(TransformException.class, () ->
|
||||||
|
{
|
||||||
fail("No exception raised");
|
retrieveTransformListBySize(data, null, "application/pdf", null, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TransformException.class)
|
@Test
|
||||||
public void buildTransformListTargetMimeTypeNullErrorTest()
|
public void buildTransformListTargetMimeTypeNullErrorTest()
|
||||||
{
|
{
|
||||||
TransformCache data = new TransformCache();
|
TransformCache data = new TransformCache();
|
||||||
|
|
||||||
retrieveTransformListBySize(data, "text/plain", null, null, null);
|
assertThrows(TransformException.class, () ->
|
||||||
|
{
|
||||||
fail("No exception raised");
|
retrieveTransformListBySize(data, "text/plain", null, null, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,9 +31,9 @@ import static java.util.stream.Collectors.toMap;
|
|||||||
import static org.alfresco.transform.registry.TransformRegistryHelper.addToPossibleTransformOptions;
|
import static org.alfresco.transform.registry.TransformRegistryHelper.addToPossibleTransformOptions;
|
||||||
import static org.alfresco.transform.registry.TransformRegistryHelper.optionsMatch;
|
import static org.alfresco.transform.registry.TransformRegistryHelper.optionsMatch;
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -48,8 +48,8 @@ import org.alfresco.transform.config.TransformOption;
|
|||||||
import org.alfresco.transform.config.TransformOptionGroup;
|
import org.alfresco.transform.config.TransformOptionGroup;
|
||||||
import org.alfresco.transform.config.TransformOptionValue;
|
import org.alfresco.transform.config.TransformOptionValue;
|
||||||
import org.alfresco.transform.config.Transformer;
|
import org.alfresco.transform.config.Transformer;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class TransformRegistryTest
|
|||||||
protected AbstractTransformRegistry registry;
|
protected AbstractTransformRegistry registry;
|
||||||
protected Map<String, Set<TransformOption>> mapOfTransformOptions;
|
protected Map<String, Set<TransformOption>> mapOfTransformOptions;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
registry = buildTransformServiceRegistryImpl();
|
registry = buildTransformServiceRegistryImpl();
|
||||||
@@ -115,17 +115,16 @@ public class TransformRegistryTest
|
|||||||
addToPossibleTransformOptions(possibleTransformOptions, transformOptionGroup, true,
|
addToPossibleTransformOptions(possibleTransformOptions, transformOptionGroup, true,
|
||||||
buildActualOptions(actualOptionNames));
|
buildActualOptions(actualOptionNames));
|
||||||
|
|
||||||
assertEquals("The expected options don't match", expectedNameSet,
|
assertEquals(expectedNameSet, possibleTransformOptions.keySet());
|
||||||
possibleTransformOptions.keySet());
|
|
||||||
|
|
||||||
possibleTransformOptions.forEach((name, required) -> {
|
possibleTransformOptions.forEach((name, required) -> {
|
||||||
if (required)
|
if (required)
|
||||||
{
|
{
|
||||||
assertTrue(name + " should be REQUIRED", expectedRequiredSet.contains(name));
|
assertTrue(expectedRequiredSet.contains(name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertFalse(name + " should be OPTIONAL", expectedRequiredSet.contains(name));
|
assertFalse(expectedRequiredSet.contains(name));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -141,12 +140,11 @@ public class TransformRegistryTest
|
|||||||
boolean supported = optionsMatch(transformOptions, buildActualOptions(actualOptionNames));
|
boolean supported = optionsMatch(transformOptions, buildActualOptions(actualOptionNames));
|
||||||
if (isBlank(unsupportedMsg))
|
if (isBlank(unsupportedMsg))
|
||||||
{
|
{
|
||||||
assertTrue("Expected these options to be SUPPORTED", supported);
|
assertTrue(supported);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertFalse("Expected these options NOT to be supported, because " + unsupportedMsg,
|
assertFalse(supported);
|
||||||
supported);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +187,7 @@ public class TransformRegistryTest
|
|||||||
buildAndPopulateRegistry(transformers);
|
buildAndPopulateRegistry(transformers);
|
||||||
String transformerName = registry.findTransformerName(sourceMimetype, sourceSizeInBytes,
|
String transformerName = registry.findTransformerName(sourceMimetype, sourceSizeInBytes,
|
||||||
targetMimetype, actualOptions, null);
|
targetMimetype, actualOptions, null);
|
||||||
assertEquals(
|
assertEquals(expectedTransformerName, transformerName);
|
||||||
sourceMimetype + " to " + targetMimetype + " should have returned " + expectedTransformerName,
|
|
||||||
expectedTransformerName, transformerName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSupported(final Transformer transformer, final String sourceMimetype,
|
private void assertSupported(final Transformer transformer, final String sourceMimetype,
|
||||||
@@ -229,13 +225,11 @@ public class TransformRegistryTest
|
|||||||
actualOptions, renditionName);
|
actualOptions, renditionName);
|
||||||
if (unsupportedMsg == null || unsupportedMsg.isEmpty())
|
if (unsupportedMsg == null || unsupportedMsg.isEmpty())
|
||||||
{
|
{
|
||||||
assertTrue(sourceMimetype + " to " + targetMimetype + " should be SUPPORTED",
|
assertTrue(supported);
|
||||||
supported);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertFalse(sourceMimetype + " to " + targetMimetype + " should NOT be supported",
|
assertFalse(supported);
|
||||||
supported);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
pom.xml
7
pom.xml
@@ -26,7 +26,6 @@
|
|||||||
<dependency.activemq.version>5.17.1</dependency.activemq.version>
|
<dependency.activemq.version>5.17.1</dependency.activemq.version>
|
||||||
<dependency.jackson.version>2.13.3</dependency.jackson.version>
|
<dependency.jackson.version>2.13.3</dependency.jackson.version>
|
||||||
<dependency.jackson-databind.version>2.13.3</dependency.jackson-databind.version>
|
<dependency.jackson-databind.version>2.13.3</dependency.jackson-databind.version>
|
||||||
<dependency.junit.version>4.13.2</dependency.junit.version>
|
|
||||||
<dependency.cxf.version>3.5.3</dependency.cxf.version>
|
<dependency.cxf.version>3.5.3</dependency.cxf.version>
|
||||||
<dependency.tika.version>2.4.1</dependency.tika.version>
|
<dependency.tika.version>2.4.1</dependency.tika.version>
|
||||||
<dependency.poi.version>5.2.2</dependency.poi.version>
|
<dependency.poi.version>5.2.2</dependency.poi.version>
|
||||||
@@ -243,12 +242,6 @@
|
|||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>1.15</version>
|
<version>1.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Junit -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>${dependency.junit.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
|
Reference in New Issue
Block a user