|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.alfresco.repo.content.transform.AbstractContentTransformerTest
public abstract class AbstractContentTransformerTest
Provides a base set of tests for testing
ContentTransformer
implementations.
Field Summary | |
---|---|
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
|
Constructor Summary | |
---|---|
AbstractContentTransformerTest()
|
Method Summary | |
---|---|
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 |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, 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, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static java.lang.String QUICK_CONTENT
protected org.springframework.context.ApplicationContext ctx
ApplicationContextHelper
protected ServiceRegistry serviceRegistry
protected org.alfresco.service.cmr.repository.MimetypeService mimetypeService
Constructor Detail |
---|
public AbstractContentTransformerTest()
Method Detail |
---|
protected abstract ContentTransformer getTransformer(java.lang.String sourceMimetype, java.lang.String targetMimetype)
sourceMimetype
- the sourceMimetype to be testedtargetMimetype
- the targetMimetype to be tested
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
public void testSetUp() throws java.lang.Exception
java.lang.Exception
public static java.io.File loadNamedQuickTestFile(java.lang.String quickname) throws java.io.IOException
the
- file required, eg quick.txt
java.io.IOException
public static java.io.File loadQuickTestFile(java.lang.String extension) throws java.io.IOException
the
- file extension required, eg txt for the file quick.txt
java.io.IOException
protected 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.IOException
public 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.Exception
protected 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 transformation
true
if phrase is expected else false
.protected boolean isQuickWordsExpected(java.lang.String targetMimetype)
targetMimetype
- mimetype of the target of the transformation
true
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
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |