mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
REPO-2724 Fix transform build error after code base split
This commit is contained in:
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 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
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* 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.repo.content.transform;
|
package org.alfresco.repo.content.transform;
|
||||||
|
|
||||||
import static org.alfresco.repo.content.transform.TransformerDebugLogTest.assertDebugEntriesEquals;
|
import static org.alfresco.repo.content.transform.TransformerDebugLogTest.assertDebugEntriesEquals;
|
||||||
@@ -32,6 +32,9 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -43,7 +46,7 @@ import org.mockito.MockitoAnnotations;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for TransformerDebug.
|
* Test class for TransformerDebug.
|
||||||
*
|
*
|
||||||
* @author Alan Davis
|
* @author Alan Davis
|
||||||
*/
|
*/
|
||||||
public class TransformerDebugTest
|
public class TransformerDebugTest
|
||||||
@@ -52,7 +55,7 @@ public class TransformerDebugTest
|
|||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private MimetypeService mimetypeService;
|
private MimetypeService mimetypeService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ContentTransformerRegistry transformerRegistry;
|
private ContentTransformerRegistry transformerRegistry;
|
||||||
@@ -62,30 +65,30 @@ public class TransformerDebugTest
|
|||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private TransformationOptions options;
|
private TransformationOptions options;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private AbstractContentTransformerLimits transformer1;
|
private AbstractContentTransformerLimits transformer1;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private AbstractContentTransformerLimits transformer2;
|
private AbstractContentTransformerLimits transformer2;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private AbstractContentTransformerLimits transformer3;
|
private AbstractContentTransformerLimits transformer3;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private AbstractContentTransformerLimits transformer4;
|
private AbstractContentTransformerLimits transformer4;
|
||||||
|
|
||||||
private TransformerDebug transformerDebug;
|
private TransformerDebug transformerDebug;
|
||||||
|
|
||||||
private TransformerLog log;
|
private TransformerLog log;
|
||||||
|
|
||||||
private TransformerDebugLog debug;
|
private TransformerDebugLog debug;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
log = new TransformerLog();
|
log = new TransformerLog();
|
||||||
debug = new TransformerDebugLog();
|
debug = new TransformerDebugLog();
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ public class TransformerDebugTest
|
|||||||
mockMimetypes(mimetypeService,
|
mockMimetypes(mimetypeService,
|
||||||
"application/pdf", "pdf",
|
"application/pdf", "pdf",
|
||||||
"text/plain", "txt");
|
"text/plain", "txt");
|
||||||
|
|
||||||
when(transformer1.getName()).thenReturn("transformer1");
|
when(transformer1.getName()).thenReturn("transformer1");
|
||||||
when(transformer2.getName()).thenReturn("transformer2");
|
when(transformer2.getName()).thenReturn("transformer2");
|
||||||
when(transformer3.getName()).thenReturn("transformer3");
|
when(transformer3.getName()).thenReturn("transformer3");
|
||||||
@@ -110,6 +113,25 @@ public class TransformerDebugTest
|
|||||||
debug.setTransformerConfig(transformerConfig);
|
debug.setTransformerConfig(transformerConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces any transformer reference numbers N.N.N with "0" before checking
|
||||||
|
private String[] unnumbered(String actual[])
|
||||||
|
{
|
||||||
|
for (int i = actual.length-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
StringJoiner sj = new StringJoiner("\n");
|
||||||
|
String[] bits = actual[i].split("\n");
|
||||||
|
for (String bit: bits)
|
||||||
|
{
|
||||||
|
Pattern p = Pattern.compile("^[0-9.]*");
|
||||||
|
Matcher m = p.matcher(bit);
|
||||||
|
bit = m.replaceFirst("0");
|
||||||
|
sj.add(bit);
|
||||||
|
}
|
||||||
|
actual[i] = sj.toString();
|
||||||
|
}
|
||||||
|
return actual;
|
||||||
|
}
|
||||||
|
|
||||||
// Replaces any times with " NN ms" before checking
|
// Replaces any times with " NN ms" before checking
|
||||||
private String[] untimed(String[] actual)
|
private String[] untimed(String[] actual)
|
||||||
{
|
{
|
||||||
@@ -124,20 +146,20 @@ public class TransformerDebugTest
|
|||||||
public void alf18373Test()
|
public void alf18373Test()
|
||||||
{
|
{
|
||||||
long sourceSize = 1024*1024*3/2;
|
long sourceSize = 1024*1024*3/2;
|
||||||
|
|
||||||
transformerDebug.pushAvailable("sourceUrl", "application/pdf", "text/plain", options);
|
transformerDebug.pushAvailable("sourceUrl", "application/pdf", "text/plain", options);
|
||||||
|
|
||||||
transformerDebug.unavailableTransformer(transformer1, "application/pdf", "text/plain", 50);
|
transformerDebug.unavailableTransformer(transformer1, "application/pdf", "text/plain", 50);
|
||||||
transformerDebug.unavailableTransformer(transformer2, "application/pdf", "text/plain", 0);
|
transformerDebug.unavailableTransformer(transformer2, "application/pdf", "text/plain", 0);
|
||||||
transformerDebug.unavailableTransformer(transformer3, "application/pdf", "text/plain", 50);
|
transformerDebug.unavailableTransformer(transformer3, "application/pdf", "text/plain", 50);
|
||||||
transformerDebug.unavailableTransformer(transformer4, "application/pdf", "text/plain", 50);
|
transformerDebug.unavailableTransformer(transformer4, "application/pdf", "text/plain", 50);
|
||||||
|
|
||||||
List<ContentTransformer> transformers = Arrays.asList(new ContentTransformer[] {});
|
List<ContentTransformer> transformers = Arrays.asList(new ContentTransformer[] {});
|
||||||
|
|
||||||
transformerDebug.availableTransformers(transformers, sourceSize, options, "ContentService.transform(...)");
|
transformerDebug.availableTransformers(transformers, sourceSize, options, "ContentService.transform(...)");
|
||||||
|
|
||||||
transformerDebug.popAvailable();
|
transformerDebug.popAvailable();
|
||||||
|
|
||||||
// "0 --c) [---] transformer4<<Component>> > 50 KB\n"+
|
// "0 --c) [---] transformer4<<Component>> > 50 KB\n"+
|
||||||
// "0 --d) [---] transformer3<<Component>> > 50 KB\n"+
|
// "0 --d) [---] transformer3<<Component>> > 50 KB\n"+
|
||||||
assertDebugEntriesEquals(new String[] {
|
assertDebugEntriesEquals(new String[] {
|
||||||
@@ -146,8 +168,8 @@ public class TransformerDebugTest
|
|||||||
"0 --a) [---] transformer1<<Component>> > 50 KB\n"+
|
"0 --a) [---] transformer1<<Component>> > 50 KB\n"+
|
||||||
"0 --b) [---] transformer3<<Component>> > 50 KB\n"+
|
"0 --b) [---] transformer3<<Component>> > 50 KB\n"+
|
||||||
"0 --c) [---] transformer4<<Component>> > 50 KB\n"+
|
"0 --c) [---] transformer4<<Component>> > 50 KB\n"+
|
||||||
"0 Finished in NN ms Transformer NOT called\n"}, untimed(debug.getEntries(10)));
|
"0 Finished in NN ms Transformer NOT called"}, unnumbered(untimed(debug.getEntries(10))));
|
||||||
assertLogEntriesEquals(new String[] {
|
assertLogEntriesEquals(new String[] {
|
||||||
"0 pdf txt WARN 1.5 MB NN ms No transformers as file is > 50 KB"}, untimed(log.getEntries(10)));
|
"0 pdf txt WARN 1.5 MB NN ms No transformers as file is > 50 KB"}, unnumbered(untimed(log.getEntries(10))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user