public abstract class AbstractContentTransformerTest
extends junit.framework.TestCase
ContentTransformer
implementations.| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.ApplicationContext |
ctx
This context will be fetched each time, but almost always
will have been cached by
ApplicationContextHelper |
protected org.alfresco.service.cmr.repository.MimetypeService |
mimetypeService |
protected static java.lang.String |
QUICK_CONTENT |
protected ServiceRegistry |
serviceRegistry |
protected TransformerDebug |
transformerDebug |
| Constructor and Description |
|---|
AbstractContentTransformerTest() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
additionalContentCheck(java.lang.String sourceMimetype,
java.lang.String targetMimetype,
java.lang.String contents)
Allows implementations to do some extra checks on the
results of the content as found by
AbstractContentTransformerTest.testAllConversions() |
protected static org.alfresco.service.cmr.repository.ContentReader |
buildContentReader(java.lang.String text,
java.nio.charset.Charset encoding)
Writes the supplied text out to a temporary file, and opens
a content reader onto it.
|
protected java.lang.String[] |
getQuickFilenames(java.lang.String sourceMimetype)
For the given mime type, returns one or more quick*
files to be tested.
|
protected abstract ContentTransformer |
getTransformer(java.lang.String sourceMimetype,
java.lang.String targetMimetype)
Fetches a transformer to test for a given transformation.
|
protected boolean |
isQuickPhraseExpected(java.lang.String targetMimetype)
This method is an extension point for enabling/disabling an assertion that the "quick brown fox"
phrase is present in the transformed content.
|
protected boolean |
isQuickWordsExpected(java.lang.String targetMimetype)
This method is an extension point for enabling/disabling an assertion that the "quick brown fox"
words are each present in the transformed content.
|
protected boolean |
isTransformationExcluded(java.lang.String sourceExtension,
java.lang.String targetExtension)
This method is an extension point for excluding certain transformations in a subclass.
|
static java.io.File |
loadNamedQuickTestFile(java.lang.String quickname)
Helper method to load one of the "The quick brown fox" files from the
classpath.
|
static java.io.File |
loadQuickTestFile(java.lang.String extension)
Helper method to load one of the "The quick brown fox" files from the
classpath.
|
protected void |
setUp()
Ensures that the temp locations are cleaned out before the tests start
|
void |
testAllConversions()
Tests the full range of transformations available on the
transformer subject to the
available test files
and the reliability of
the transformer itself. |
void |
testSetUp()
Check that all objects are present
|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toStringassertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, formatprotected static java.lang.String QUICK_CONTENT
protected org.springframework.context.ApplicationContext ctx
ApplicationContextHelperprotected ServiceRegistry serviceRegistry
protected org.alfresco.service.cmr.repository.MimetypeService mimetypeService
protected TransformerDebug transformerDebug
protected abstract ContentTransformer getTransformer(java.lang.String sourceMimetype, java.lang.String targetMimetype)
sourceMimetype - the sourceMimetype to be testedtargetMimetype - the targetMimetype to be testedprotected void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exceptionpublic void testSetUp()
throws java.lang.Exception
java.lang.Exceptionpublic static java.io.File loadNamedQuickTestFile(java.lang.String quickname)
throws java.io.IOException
the - file required, eg quick.txtjava.io.IOExceptionpublic static java.io.File loadQuickTestFile(java.lang.String extension)
throws java.io.IOException
the - file extension required, eg txt for the file quick.txtjava.io.IOExceptionprotected java.lang.String[] getQuickFilenames(java.lang.String sourceMimetype)
protected static org.alfresco.service.cmr.repository.ContentReader buildContentReader(java.lang.String text,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptionpublic void testAllConversions()
throws java.lang.Exception
transformer subject to the
available test files
and the reliability of
the transformer itself.
Each transformation is repeated several times, with a transformer being
requested for each transformation. In the
case where optimizations are being done around the selection of the most
appropriate transformer, different transformers could be used during the iteration
process.
Results for the transformations are dumped to a temporary file named AbstractContentTransformerTest-results-1234.txt.
java.lang.Exceptionprotected void additionalContentCheck(java.lang.String sourceMimetype,
java.lang.String targetMimetype,
java.lang.String contents)
AbstractContentTransformerTest.testAllConversions()protected boolean isQuickPhraseExpected(java.lang.String targetMimetype)
targetMimetype - mimetype of the target of the transformationtrue if phrase is expected else false.protected boolean isQuickWordsExpected(java.lang.String targetMimetype)
targetMimetype - mimetype of the target of the transformationtrue if each word is expected else false.protected boolean isTransformationExcluded(java.lang.String sourceExtension,
java.lang.String targetExtension)
false for all mime type pairs.sourceExtension - targetExtension - Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.