FileDocCategorySizeDatePackage
ImageTest.javaAPI DocApache Ant 1.703839Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.image

ImageTest

public class ImageTest extends org.apache.tools.ant.BuildFileTest
Tests the Image task.
since
Ant 1.5

Fields Summary
private static final String
TASKDEFS_DIR
private static final String
LARGEIMAGE
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
Constructors Summary
public ImageTest(String name)


       
        super(name);
    
Methods Summary
protected java.io.FilecreateRelativeFile(java.lang.String filename)

        if (filename.equals(".")) {
            return getProjectDir();
        }
        // else
        return new File(getProjectDir(), filename);
    
public voidoff_testFailOnError()

        try {
            expectLogContaining("testFailOnError", 
                                "Unable to process image stream");
        }
        catch (RuntimeException re){
            assertTrue("Run time exception should say "
                       + "'Unable to process image stream'. :" 
                       + re.toString(),
                       re.toString()
                       .indexOf("Unable to process image stream") > -1);
        }
    
public voidsetUp()

        configureProject(TASKDEFS_DIR + "image.xml");
    
public voidtearDown()

        executeTarget("cleanup");
    
public voidtestEchoToLog()

        expectLogContaining("testEchoToLog", "Processing File");
    
public voidtestOverwriteFalse()

        expectLogContaining("testSimpleScale", "Processing File");
        File f = createRelativeFile("/dest/" + LARGEIMAGE);
        long lastModified = f.lastModified();
        expectLogContaining("testOverwriteFalse", "Processing File");
        f = createRelativeFile("/dest/" + LARGEIMAGE);
        long overwrittenLastModified = f.lastModified();
        assertTrue("File was overwritten.",
                   lastModified == overwrittenLastModified);
    
public voidtestOverwriteTrue()

        expectLogContaining("testSimpleScale", "Processing File");
        File f = createRelativeFile("/dest/" + LARGEIMAGE);
        long lastModified = f.lastModified();
        try {
            Thread.sleep(FILE_UTILS
                         .getFileTimestampGranularity());
        }
        catch (InterruptedException e) {}
        expectLogContaining("testOverwriteTrue", "Processing File");
        f = createRelativeFile("/dest/" + LARGEIMAGE);
        long overwrittenLastModified = f.lastModified();
        assertTrue("File was not overwritten.",
                   lastModified < overwrittenLastModified);
    
public voidtestSimpleScale()

        expectLogContaining("testSimpleScale", "Processing File");
        File f = createRelativeFile("/dest/" + LARGEIMAGE);
        assertTrue(
                   "Did not create "+f.getAbsolutePath(),
                   f.exists());