org.alfresco.repo.content.transform
Class AbstractContentTransformerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.alfresco.repo.content.transform.AbstractContentTransformerTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
BinaryPassThroughContentTransformerTest, ComplexContentTransformerTest, ContentTransformerRegistryTest, FailoverContentTransformerTest, HtmlParserContentTransformerTest, ImageMagickContentTransformerTest, MailContentTransformerTest, MediaWikiContentTransformerTest, OpenOfficeContentTransformerTest, PdfBoxContentTransformerTest, PoiHssfContentTransformerTest, StringExtractingContentTransformerTest, TextMiningContentTransformerTest, TextToPdfContentTransformerTest

public abstract class AbstractContentTransformerTest
extends junit.framework.TestCase

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  MimetypeService mimetypeService
           
protected static java.lang.String QUICK_CONTENT
           
protected  ServiceRegistry serviceRegistry
           
 
Constructor Summary
AbstractContentTransformerTest()
           
 
Method Summary
protected abstract  ContentTransformer getTransformer(java.lang.String sourceMimetype, java.lang.String targetMimetype)
          Fetches a transformer to test for a given transformation.
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 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

QUICK_CONTENT

protected static java.lang.String QUICK_CONTENT

ctx

protected org.springframework.context.ApplicationContext ctx
This context will be fetched each time, but almost always will have been cached by ApplicationContextHelper


serviceRegistry

protected ServiceRegistry serviceRegistry

mimetypeService

protected MimetypeService mimetypeService
Constructor Detail

AbstractContentTransformerTest

public AbstractContentTransformerTest()
Method Detail

getTransformer

protected abstract ContentTransformer getTransformer(java.lang.String sourceMimetype,
                                                     java.lang.String targetMimetype)
Fetches a transformer to test for a given transformation. The transformer does not have to be reliable for the given format - if it isn't then it will be ignored.

Parameters:
sourceMimetype - the sourceMimetype to be tested
targetMimetype - the targetMimetype to be tested
Returns:
Returns the ContentTranslators that will be tested by the methods implemented in this class. A null return value is acceptable if the source and target mimetypes are not of interest.

setUp

protected void setUp()
              throws java.lang.Exception
Ensures that the temp locations are cleaned out before the tests start

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testSetUp

public void testSetUp()
               throws java.lang.Exception
Check that all objects are present

Throws:
java.lang.Exception

loadQuickTestFile

public static java.io.File loadQuickTestFile(java.lang.String extension)
                                      throws java.io.IOException
Helper method to load one of the "The quick brown fox" files from the classpath.

Parameters:
extension - the extension of the file required, e.g. txt
Returns:
Returns a test resource loaded from the classpath or null if no resource could be found.
Throws:
java.io.IOException

testAllConversions

public void testAllConversions()
                        throws java.lang.Exception
Tests the full range of transformations available on the 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.

Throws:
java.lang.Exception

isTransformationExcluded

protected boolean isTransformationExcluded(java.lang.String sourceExtension,
                                           java.lang.String targetExtension)
This method is an extension point for excluding certain transformations in a subclass. The default implementation returns false for all mime type pairs.

Parameters:
sourceExtension -
targetExtension -
Returns:


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.