mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
[MNT-23567] Prepare proof of work test for PPT to TXT Transformation.
Use for testing: docker compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile with-transform-core-aio up -d
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -460,7 +460,7 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest
|
|||||||
return testFileName;
|
return testFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef createContentNodeFromQuickFile(String fileName) throws FileNotFoundException
|
protected NodeRef createContentNodeFromQuickFile(String fileName) throws FileNotFoundException
|
||||||
{
|
{
|
||||||
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||||
NodeRef folderNodeRef = nodeService.createNode(
|
NodeRef folderNodeRef = nodeService.createNode(
|
||||||
|
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Repository
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2025 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.util;
|
||||||
|
|
||||||
|
import org.alfresco.repo.rendition2.AbstractRenditionIntegrationTest;
|
||||||
|
import org.alfresco.repo.rendition2.SynchronousTransformClient;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.alfresco.model.ContentModel.PROP_CONTENT;
|
||||||
|
|
||||||
|
public class PPTtoTextTransformationTest extends AbstractRenditionIntegrationTest
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
protected SynchronousTransformClient localSynchronousTransformClient;
|
||||||
|
|
||||||
|
protected SynchronousTransformClient synchronousTransformClient;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void before()
|
||||||
|
{
|
||||||
|
AbstractRenditionIntegrationTest.before();
|
||||||
|
local();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void after()
|
||||||
|
{
|
||||||
|
// Strict MimetypeCheck property cleanup
|
||||||
|
System.clearProperty("transformer.strict.mimetype.check");
|
||||||
|
// Retry on DifferentMimetype property cleanup
|
||||||
|
System.clearProperty("content.transformer.retryOn.different.mimetype");
|
||||||
|
AbstractRenditionIntegrationTest.after();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception
|
||||||
|
{
|
||||||
|
super.setUp();
|
||||||
|
AuthenticationUtil.setRunAsUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
synchronousTransformClient = localSynchronousTransformClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransformPttToTxt() throws Exception
|
||||||
|
{
|
||||||
|
checkTransform("quick.ppt", "text/plain", Collections.emptyMap(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkTransform(String testFileName, String targetMimetype, Map<String, String> actualOptions, boolean expectedToPass)
|
||||||
|
{
|
||||||
|
if (expectedToPass)
|
||||||
|
{
|
||||||
|
NodeRef sourceNode = transactionService.getRetryingTransactionHelper().doInTransaction(() ->
|
||||||
|
createContentNodeFromQuickFile(testFileName));
|
||||||
|
ContentReader reader = contentService.getReader(sourceNode, PROP_CONTENT);
|
||||||
|
ContentWriter writer = contentService.getTempWriter();
|
||||||
|
writer.setMimetype(targetMimetype);
|
||||||
|
synchronousTransformClient.transform(reader, writer, actualOptions, null, sourceNode);
|
||||||
|
|
||||||
|
ContentReader transformReader = writer.getReader();
|
||||||
|
String content = transformReader == null ? null : transformReader.getContentString();
|
||||||
|
content = content == null || content.isEmpty() ? null : content;
|
||||||
|
assertNotNull("The synchronous transform resulted in no content", content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -3,7 +3,7 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
transform-core-aio:
|
transform-core-aio:
|
||||||
profiles: ["with-transform-core-aio"]
|
profiles: ["with-transform-core-aio"]
|
||||||
image: alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG}
|
image: alfresco/alfresco-transform-core-aio:5.1.3
|
||||||
environment:
|
environment:
|
||||||
JAVA_OPTS: " -Xms256m -Xmx256m"
|
JAVA_OPTS: " -Xms256m -Xmx256m"
|
||||||
ports:
|
ports:
|
||||||
|
Reference in New Issue
Block a user