ACS-373: Fix tika proble UnsupportedOperationException (#264)

This commit is contained in:
eknizat 2020-06-23 16:52:49 +01:00 committed by GitHub
parent d3defc8071
commit 522c793970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import java.io.File; import java.io.File;
import java.util.Collections; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.alfresco.transformer.executors.Tika.PDF_BOX; import static org.alfresco.transformer.executors.Tika.PDF_BOX;
@ -92,7 +92,7 @@ public class TikaController extends AbstractTransformerController
@Override @Override
protected void executeTransformCommand(File sourceFile, File targetFile) protected void executeTransformCommand(File sourceFile, File targetFile)
{ {
transformImpl(PDF_BOX, MIMETYPE_PDF, MIMETYPE_TEXT_PLAIN, Collections.emptyMap(), sourceFile, targetFile); transformImpl(PDF_BOX, MIMETYPE_PDF, MIMETYPE_TEXT_PLAIN, new HashMap<>(), sourceFile, targetFile);
} }
}; };
} }

View File

@ -31,6 +31,7 @@ import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transformer.executors.RuntimeExec; import org.alfresco.transformer.executors.RuntimeExec;
import org.alfresco.transformer.model.FileRefEntity; import org.alfresco.transformer.model.FileRefEntity;
import org.alfresco.transformer.model.FileRefResponse; import org.alfresco.transformer.model.FileRefResponse;
import org.alfresco.transformer.probes.ProbeTestTransform;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -44,10 +45,12 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -269,6 +272,18 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
.param("sourceMimetype", sourceMimetype); .param("sourceMimetype", sourceMimetype);
} }
@Mock
HttpServletRequest httpServletRequest;
@Test
public void testImmutableEmptyMap()
{
// See ACS-373
ProbeTestTransform probeTestTransform = getController().getProbeTestTransform();
ReflectionTestUtils.setField(probeTestTransform, "livenessTransformEnabled", true);
probeTestTransform.doTransformOrNothing(httpServletRequest, true);
}
@Test @Test
@Override @Override
public void simpleTransformTest() throws Exception public void simpleTransformTest() throws Exception