ro.isdc.wro.util
Class WroTestUtils

java.lang.Object
  extended by ro.isdc.wro.util.WroTestUtils

public class WroTestUtils
extends Object

WroTestUtils.

Author:
Alex Objelean

Constructor Summary
WroTestUtils()
           
 
Method Summary
static void compare(InputStream expected, InputStream actual)
          Compare if content of expected stream is the same as content of the actual stream.
static void compare(InputStream input, InputStream expected, ResourcePostProcessor processor)
           
static void compare(Reader resultReader, Reader expectedReader, ResourcePostProcessor processor)
          Compare contents of two resources (files) by performing some sort of processing on input resource.
static void compare(String expected, String actual)
          Compares two strings by removing trailing spaces & tabs for correct comparison.
static void compareFromDifferentFolders(File sourceFolder, File targetFolder, org.apache.commons.io.filefilter.IOFileFilter fileFilter, ResourcePostProcessor processor)
          Process and compare the files which a located in different folders.
static void compareFromDifferentFolders(File sourceFolder, File targetFolder, org.apache.commons.io.filefilter.IOFileFilter fileFilter, Transformer<String> toTargetFileName, ResourcePostProcessor processor)
           
static void compareFromDifferentFolders(File sourceFolder, File targetFolder, org.apache.commons.io.filefilter.IOFileFilter fileFilter, Transformer<String> toTargetFileName, ResourcePreProcessor preProcessor)
          Process and compare the files which a located in different folders.
static void compareFromDifferentFolders(File sourceFolder, File targetFolder, ResourcePostProcessor processor)
           
static void compareFromDifferentFolders(File sourceFolder, File targetFolder, ResourcePreProcessor processor)
          Process and compare all the files from the sourceFolder and compare them with the files from the targetFolder.
static void compareFromDifferentFoldersByExtension(File sourceFolder, File targetFolder, String extension, ResourcePostProcessor processor)
          TODO run tests in parallel
static void compareFromDifferentFoldersByExtension(File sourceFolder, File targetFolder, String extension, ResourcePreProcessor processor)
           
static void compareFromSameFolder(File sourceFolder, org.apache.commons.io.filefilter.IOFileFilter sourceFileFilter, Transformer<String> toTargetFileName, ResourcePostProcessor processor)
          Process and compare files from the same folder.
static void compareFromSameFolder(File sourceFolder, org.apache.commons.io.filefilter.IOFileFilter sourceFileFilter, Transformer<String> toTargetFileName, ResourcePreProcessor processor)
           
static void compareProcessedResourceContents(String inputResourceUri, String expectedContentResourceUri, ResourcePostProcessor processor)
          Compare contents of two resources (files) by performing some sort of processing on input resource.
static void compareProcessedResourceContents(String inputResourceUri, String expectedContentResourceUri, ResourcePreProcessor processor)
           
static void compareSameFolderByExtension(File sourceFolder, String sourceFileExtension, String targetFileExtension, ResourcePostProcessor processor)
          Process and compare files from the same folder.
static void compareSameFolderByExtension(File sourceFolder, String sourceFileExtension, String targetFileExtension, ResourcePreProcessor processor)
           
static void compareSameFolderByExtension(File sourceFolder, String sourceFileExtension, Transformer<String> toTargetFileName, ResourcePostProcessor processor)
           
static InputStream getInputStream(String uri)
           
static InputStream getPropertiesStream(Properties properties)
           
static void init(WroModelFactory factory)
           
static void initProcessor(ResourcePostProcessor processor)
           
static void initProcessor(ResourcePreProcessor processor)
           
static void runConcurrently(Callable<Void> task)
          Runs a task concurrently.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WroTestUtils

public WroTestUtils()
Method Detail

getPropertiesStream

public static InputStream getPropertiesStream(Properties properties)
Parameters:
properties - Properties object to get stream from.
Returns:
InputStream of the provided properties object.

compareProcessedResourceContents

public static void compareProcessedResourceContents(String inputResourceUri,
                                                    String expectedContentResourceUri,
                                                    ResourcePostProcessor processor)
                                             throws IOException
Compare contents of two resources (files) by performing some sort of processing on input resource.

Parameters:
inputResourceUri - uri of the resource to process.
expectedContentResourceUri - uri of the resource to compare with processed content.
processor - a closure used to process somehow the input content.
Throws:
IOException

compareProcessedResourceContents

public static void compareProcessedResourceContents(String inputResourceUri,
                                                    String expectedContentResourceUri,
                                                    ResourcePreProcessor processor)
                                             throws IOException
Throws:
IOException

getInputStream

public static InputStream getInputStream(String uri)
                                  throws IOException
Throws:
IOException

init

public static void init(WroModelFactory factory)

initProcessor

public static void initProcessor(ResourcePreProcessor processor)

initProcessor

public static void initProcessor(ResourcePostProcessor processor)

compare

public static void compare(Reader resultReader,
                           Reader expectedReader,
                           ResourcePostProcessor processor)
                    throws IOException
Compare contents of two resources (files) by performing some sort of processing on input resource.

Parameters:
inputResourceUri - uri of the resource to process.
expectedContentResourceUri - uri of the resource to compare with processed content.
processor - a closure used to process somehow the input content.
Throws:
IOException

compare

public static void compare(InputStream input,
                           InputStream expected,
                           ResourcePostProcessor processor)
                    throws IOException
Throws:
IOException

compare

public static void compare(InputStream expected,
                           InputStream actual)
                    throws IOException
Compare if content of expected stream is the same as content of the actual stream.

Parameters:
expected - InputStream of the expected content.
actual - InputStream of the actual content.
Throws:
IOException

compare

public static void compare(String expected,
                           String actual)
Compares two strings by removing trailing spaces & tabs for correct comparison.


compareSameFolderByExtension

public static void compareSameFolderByExtension(File sourceFolder,
                                                String sourceFileExtension,
                                                String targetFileExtension,
                                                ResourcePostProcessor processor)
                                         throws IOException
Process and compare files from the same folder. Use the extension to make distinction between the source files (files to process) and target files (files to compare with).

Parameters:
sourceFolder - the folder where the files to compare resides.
sourceFileExtension - the extension of the files used to process.
targetFileExtension - the extension of the files used to compare with the processed result.
processor - ResourcePostProcessor to apply on input files.
Throws:
IOException

compareSameFolderByExtension

public static void compareSameFolderByExtension(File sourceFolder,
                                                String sourceFileExtension,
                                                String targetFileExtension,
                                                ResourcePreProcessor processor)
                                         throws IOException
Throws:
IOException

compareSameFolderByExtension

public static void compareSameFolderByExtension(File sourceFolder,
                                                String sourceFileExtension,
                                                Transformer<String> toTargetFileName,
                                                ResourcePostProcessor processor)
                                         throws IOException
Parameters:
sourceFolder -
sourceFileExtension -
toTargetFileName -
processor -
Throws:
IOException
See Also:
Same as {@link WroTestUtils#compareSameFolderByExtension(File, String, String, ResourcePostProcessor)}, but let you define the way target file name is named.

compareFromSameFolder

public static void compareFromSameFolder(File sourceFolder,
                                         org.apache.commons.io.filefilter.IOFileFilter sourceFileFilter,
                                         Transformer<String> toTargetFileName,
                                         ResourcePostProcessor processor)
                                  throws IOException
Process and compare files from the same folder.

Parameters:
sourceFolder - the folder where the files to compare resides.
sourceFileFilter - the IOFileFilter used to select source files (files to be processed).
toTargetFileName - the Transformer which creates the name of the target file used to compare with the source processed content.
processor - ResourcePostProcessor to apply on source files.
Throws:
IOException

compareFromSameFolder

public static void compareFromSameFolder(File sourceFolder,
                                         org.apache.commons.io.filefilter.IOFileFilter sourceFileFilter,
                                         Transformer<String> toTargetFileName,
                                         ResourcePreProcessor processor)
                                  throws IOException
Throws:
IOException

compareFromDifferentFolders

public static void compareFromDifferentFolders(File sourceFolder,
                                               File targetFolder,
                                               org.apache.commons.io.filefilter.IOFileFilter fileFilter,
                                               ResourcePostProcessor processor)
                                        throws IOException
Process and compare the files which a located in different folders.

Throws:
IOException

compareFromDifferentFolders

public static void compareFromDifferentFolders(File sourceFolder,
                                               File targetFolder,
                                               ResourcePreProcessor processor)
                                        throws IOException
Process and compare all the files from the sourceFolder and compare them with the files from the targetFolder.

Throws:
IOException

compareFromDifferentFolders

public static void compareFromDifferentFolders(File sourceFolder,
                                               File targetFolder,
                                               ResourcePostProcessor processor)
                                        throws IOException
Throws:
IOException

compareFromDifferentFoldersByExtension

public static void compareFromDifferentFoldersByExtension(File sourceFolder,
                                                          File targetFolder,
                                                          String extension,
                                                          ResourcePreProcessor processor)
                                                   throws IOException
Throws:
IOException

compareFromDifferentFoldersByExtension

public static void compareFromDifferentFoldersByExtension(File sourceFolder,
                                                          File targetFolder,
                                                          String extension,
                                                          ResourcePostProcessor processor)
                                                   throws IOException
TODO run tests in parallel

Throws:
IOException

compareFromDifferentFolders

public static void compareFromDifferentFolders(File sourceFolder,
                                               File targetFolder,
                                               org.apache.commons.io.filefilter.IOFileFilter fileFilter,
                                               Transformer<String> toTargetFileName,
                                               ResourcePostProcessor processor)
                                        throws IOException
Throws:
IOException

compareFromDifferentFolders

public static void compareFromDifferentFolders(File sourceFolder,
                                               File targetFolder,
                                               org.apache.commons.io.filefilter.IOFileFilter fileFilter,
                                               Transformer<String> toTargetFileName,
                                               ResourcePreProcessor preProcessor)
                                        throws IOException
Process and compare the files which a located in different folders.

Parameters:
sourceFolder - folder where the source files are located.
targetFolder - folder where the target files are located.
fileFilter - filter used to select files to process.
toTargetFileName - Transformer used to identify the target file name based on source file name.
preProcessor - ResourcePreProcessor used to process the source files.
Throws:
IOException

runConcurrently

public static void runConcurrently(Callable<Void> task)
                            throws Exception
Runs a task concurrently. Allows to test thread-safe behavior.

Parameters:
task - a Callable to run concurrently.
Throws:
Exception - if any of the executed tasks fails.


Copyright © 2008-2011. All Rights Reserved.