mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
REPO-1995 TransformerDebugTest
There was a leading date on the log message and the code to zero out the trans ref did not know that.
This commit is contained in:
@@ -25,17 +25,6 @@
|
||||
*/
|
||||
package org.alfresco.repo.content.transform;
|
||||
|
||||
import static org.alfresco.repo.content.transform.TransformerDebugLogTest.assertDebugEntriesEquals;
|
||||
import static org.alfresco.repo.content.transform.TransformerLogTest.assertLogEntriesEquals;
|
||||
import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
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.NodeService;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
@@ -44,6 +33,18 @@ import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.alfresco.repo.content.transform.TransformerDebugLogTest.assertDebugEntriesEquals;
|
||||
import static org.alfresco.repo.content.transform.TransformerLogTest.stripDateStamp;
|
||||
import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test class for TransformerDebug.
|
||||
*
|
||||
@@ -142,15 +143,6 @@ public class TransformerDebugTest
|
||||
return actual;
|
||||
}
|
||||
|
||||
private String[] stripCR(String[] actual)
|
||||
{
|
||||
for (int i = actual.length-1; i >= 0; i--)
|
||||
{
|
||||
actual[i] = actual[i].replaceAll(" \r", "");
|
||||
}
|
||||
return actual;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alf18373Test()
|
||||
{
|
||||
@@ -169,16 +161,14 @@ public class TransformerDebugTest
|
||||
|
||||
transformerDebug.popAvailable();
|
||||
|
||||
// "0 --c) [---] transformer4<<Component>> > 50 KB\n"+
|
||||
// "0 --d) [---] transformer3<<Component>> > 50 KB\n"+
|
||||
assertDebugEntriesEquals(new String[] {
|
||||
"0 pdf txt 1.5 MB ContentService.transform(...) NO transformers\n"+
|
||||
"0 \n"+
|
||||
"0 --a) [---] transformer1<<Component>> > 50 KB\n"+
|
||||
"0 --b) [---] transformer3<<Component>> > 50 KB\n"+
|
||||
"0 --c) [---] transformer4<<Component>> > 50 KB\n"+
|
||||
"0 Finished in NN ms Transformer NOT called"}, unnumbered(untimed(stripCR(debug.getEntries(10)))));
|
||||
assertLogEntriesEquals(new String[] {
|
||||
"0 pdf txt WARN 1.5 MB NN ms No transformers as file is > 50 KB"}, unnumbered(untimed(stripCR(log.getEntries(10)))));
|
||||
"0 Finished in NN ms Transformer NOT called"}, unnumbered(untimed(debug.getEntries(10))));
|
||||
assertArrayEquals(new String[] {
|
||||
"0 pdf txt WARN 1.5 MB NN ms No transformers as file is > 50 KB"}, unnumbered(untimed(stripDateStamp(log.getEntries(10)))));
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.repo.content.transform;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
@@ -60,15 +60,19 @@ public class TransformerLogTest
|
||||
log.setTransformerConfig(transformerConfig);
|
||||
}
|
||||
|
||||
static void assertLogEntriesEquals(String[] expected, String[] actual)
|
||||
static String[] stripDateStamp(String[] actual)
|
||||
{
|
||||
// Strip the date prefix
|
||||
int beginIndex = (TransformerLogger.DATE_FORMAT.format(new Date())+' ').length();
|
||||
for (int i=actual.length-1; i >= 0; i--)
|
||||
for (int i = actual.length-1; i >= 0; i--)
|
||||
{
|
||||
actual[i] = actual[i].substring(beginIndex);
|
||||
}
|
||||
assertArrayEquals(expected, actual);
|
||||
return actual;
|
||||
}
|
||||
|
||||
static void assertLogEntriesEquals(String[] expected, String[] actual)
|
||||
{
|
||||
assertArrayEquals(expected, stripDateStamp(actual));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user