org.alfresco.repo.content.metadata
Class AbstractMetadataExtracterTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.alfresco.repo.content.metadata.AbstractMetadataExtracterTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
DWGMetadataExtracterTest, HtmlMetadataExtracterTest, MailMetadataExtracterTest, MP3MetadataExtracterTest, OfficeMetadataExtracterTest, OpenDocumentMetadataExtracterTest, OpenOfficeMetadataExtracterTest, PdfBoxMetadataExtracterTest, PoiMetadataExtracterTest, RFC822MetadataExtracterTest, TikaAutoMetadataExtracterTest

public abstract class AbstractMetadataExtracterTest
extends junit.framework.TestCase

See Also:
MetadataExtracter, AbstractMetadataExtracter

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.dictionary.DictionaryService dictionaryService
           
protected  org.alfresco.repo.content.MimetypeMap mimetypeMap
           
static java.lang.String QUICK_CREATOR
           
static java.lang.String QUICK_CREATOR_EMAIL
           
static java.lang.String QUICK_DESCRIPTION
           
static java.lang.String QUICK_PREVIOUS_AUTHOR
           
static java.lang.String QUICK_TITLE
           
 
Constructor Summary
AbstractMetadataExtracterTest()
           
 
Method Summary
protected static void assertContains(java.lang.String needle, java.lang.String haystack)
           
protected static void assertContains(java.lang.String message, java.lang.String needle, java.lang.String haystack)
           
protected  java.util.Map extractFromFile(java.io.File sourceFile, java.lang.String mimetype)
           
protected  java.util.Map extractFromMimetype(java.lang.String mimetype)
           
protected abstract  MetadataExtracter getExtracter()
           
 void setUp()
          Ensures that the temp locations are cleaned out before the tests start
protected  boolean skipAuthorCheck(java.lang.String mimetype)
          This method can be overridden to cause the author/creator property check to be skipped.
protected  boolean skipDescriptionCheck(java.lang.String mimetype)
          This method can be overridden to cause the description property check to be skipped.
protected  void testCommonMetadata(java.lang.String mimetype, java.util.Map properties)
          Tests that we can get the common metadata correctly from the file.
protected  void testExtractFromMimetype(java.lang.String mimetype)
           
protected abstract  void testFileSpecificMetadata(java.lang.String mimetype, java.util.Map properties)
           
 void testSetUp()
          Check that all objects are present
 void testZeroLengthFile()
           
 
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

ctx

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


QUICK_TITLE

public static final java.lang.String QUICK_TITLE
See Also:
Constant Field Values

QUICK_DESCRIPTION

public static final java.lang.String QUICK_DESCRIPTION
See Also:
Constant Field Values

QUICK_CREATOR

public static final java.lang.String QUICK_CREATOR
See Also:
Constant Field Values

QUICK_CREATOR_EMAIL

public static final java.lang.String QUICK_CREATOR_EMAIL
See Also:
Constant Field Values

QUICK_PREVIOUS_AUTHOR

public static final java.lang.String QUICK_PREVIOUS_AUTHOR
See Also:
Constant Field Values

mimetypeMap

protected org.alfresco.repo.content.MimetypeMap mimetypeMap

dictionaryService

protected org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService
Constructor Detail

AbstractMetadataExtracterTest

public AbstractMetadataExtracterTest()
Method Detail

getExtracter

protected abstract MetadataExtracter getExtracter()

setUp

public 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

testExtractFromMimetype

protected void testExtractFromMimetype(java.lang.String mimetype)
                                throws java.lang.Exception
Throws:
java.lang.Exception

extractFromMimetype

protected java.util.Map extractFromMimetype(java.lang.String mimetype)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

extractFromFile

protected java.util.Map extractFromFile(java.io.File sourceFile,
                                        java.lang.String mimetype)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testCommonMetadata

protected void testCommonMetadata(java.lang.String mimetype,
                                  java.util.Map properties)
Tests that we can get the common metadata correctly from the file. You only need to override this if your test data file doesn't have the usual Nevin Nollop/quick brown fox data in it.


testFileSpecificMetadata

protected abstract void testFileSpecificMetadata(java.lang.String mimetype,
                                                 java.util.Map properties)

skipAuthorCheck

protected boolean skipAuthorCheck(java.lang.String mimetype)
This method can be overridden to cause the author/creator property check to be skipped. The default behaviour is for the check not to be skipped for all MIME types.

Parameters:
mimetype -
Returns:
true to skip the checks, else false

skipDescriptionCheck

protected boolean skipDescriptionCheck(java.lang.String mimetype)
This method can be overridden to cause the description property check to be skipped. The default behaviour is for the check not to be skipped for all MIME types.

Parameters:
mimetype -
Returns:
true to skip the checks, else false

testZeroLengthFile

public void testZeroLengthFile()
                        throws java.lang.Exception
Throws:
java.lang.Exception

assertContains

protected static void assertContains(java.lang.String message,
                                     java.lang.String needle,
                                     java.lang.String haystack)

assertContains

protected static void assertContains(java.lang.String needle,
                                     java.lang.String haystack)


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