org.unitils.io.annotation.handler
Class FileContentAnnotationHandler
java.lang.Object
org.unitils.core.TestListener
org.unitils.io.annotation.handler.FileContentAnnotationHandler
public class FileContentAnnotationHandler
- extends TestListener
Implements the behavior of the FileContent
annotation.
See annotation javadoc for more info.
- Since:
- 3.3
- Author:
- Jeroen Horemans, Tim Ducheyne, Thomas De Rycke
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileContentAnnotationHandler
public FileContentAnnotationHandler(FileContentReader fileContentReader)
- Parameters:
fileContentReader
- The content reader implementation, not null
beforeTestSetUp
public void beforeTestSetUp(Object testObject,
Method testMethod)
- All fields that have an
FileContent
annotation will be handled before the setup of the test.
This will convert the content of the requested file to the target type of the field and inject the
result into the field.
- Overrides:
beforeTestSetUp
in class TestListener
- Parameters:
testObject
- The test instance, not nulltestMethod
- The test method, not null
readFileContentForField
protected void readFileContentForField(Object testObject,
Field field)
- Does the actual content reading and injection for the given field.
- Parameters:
testObject
- The test instance, not nullfield
- The field with the FileContent annotation, not null
determineEncoding
protected String determineEncoding(FileContent fileContentAnnotation)
- Parameters:
fileContentAnnotation
- The annotation, not null
- Returns:
- the encoding specified in the annotation, null if no encoding was specified
determineFileName
protected String determineFileName(FileContent fileContentAnnotation)
- Parameters:
fileContentAnnotation
- The annotation, not null
- Returns:
- the file name specified in the annotation, null if no file name was specified
Copyright © 2011. All Rights Reserved.