ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional/image ImageTest.java
Date Wed, 31 Mar 2004 09:07:22 GMT
bodewig     2004/03/31 01:07:22

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/image
                        Image.java
               src/testcases/org/apache/tools/ant/taskdefs/optional/image
                        ImageTest.java
  Log:
  Whitespace changes only
  
  Revision  Changes    Path
  1.11      +25 -22    ant/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
  
  Index: Image.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Image.java	9 Mar 2004 16:48:29 -0000	1.10
  +++ Image.java	31 Mar 2004 09:07:22 -0000	1.11
  @@ -37,15 +37,14 @@
   import java.util.Vector;
   
   /**
  - * A MatchingTask which relies on
  - * <A HREF="http://java.sun.com/products/java-media/jai">JAI (Java Advanced Imaging)</A>
  - * to perform image manipulation operations on existing images.  The
  - * operations are represented as ImageOperation DataType objects.
  - * The operations are arranged to conform to the Chaining Model
  - * of JAI.
  - * Check out the
  - * <A HREF="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/">
  - *   JAI Programming Guide</A>
  + * A MatchingTask which relies on <A
  + * HREF="http://java.sun.com/products/java-media/jai">JAI (Java
  + * Advanced Imaging)</A> to perform image manipulation operations on
  + * existing images.  The operations are represented as ImageOperation
  + * DataType objects.  The operations are arranged to conform to the
  + * Chaining Model of JAI.  Check out the <A
  + * HREF="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/">
  + * JAI Programming Guide</A>
    *
    * @see org.apache.tools.ant.types.optional.image.ImageOperation
    * @see org.apache.tools.ant.types.DataType
  @@ -85,9 +84,9 @@
       }
   
       /**
  -     * Set the image encoding type.
  -     * <A HREF="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#56610">
  -     *     See this table in the JAI Programming Guide</A>.
  +     * Set the image encoding type.  <A
  +     * HREF="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#56610">
  +     * See this table in the JAI Programming Guide</A>.
        */
       public void setEncoding(String encoding) {
           str_encoding = encoding;
  @@ -101,7 +100,8 @@
       }
   
       /**
  -     *  Enables Garbage Collection after each image processed.  Defaults to false.
  +     *  Enables Garbage Collection after each image processed.
  +     *  Defaults to false.
        */
       public void setGc(boolean gc) {
           garbage_collect = gc;
  @@ -166,7 +166,8 @@
               for (int i = 0; i < instructions.size(); i++) {
                   Object instr = instructions.elementAt(i);
                   if (instr instanceof TransformOperation) {
  -                    image = ((TransformOperation) instr).executeTransformOperation(image);
  +                    image = ((TransformOperation) instr)
  +                        .executeTransformOperation(image);
                   } else {
                       log("Not a TransformOperation: " + instr);
                   }
  @@ -183,7 +184,8 @@
                   destDir = srcDir;
               }
   
  -            File new_file = new File(destDir.getAbsolutePath() + File.separator + file.getName());
  +            File new_file = new File(destDir.getAbsolutePath() 
  +                                     + File.separator + file.getName());
   
               if ((overwrite && new_file.exists()) && (!new_file.equals(file)))
{
                   new_file.delete();
  @@ -191,7 +193,8 @@
   
               FileOutputStream stream = new FileOutputStream(new_file);
   
  -            JAI.create("encode", image, stream, str_encoding.toUpperCase(), null);
  +            JAI.create("encode", image, stream, str_encoding.toUpperCase(), 
  +                       null);
               stream.flush();
               stream.close();
   
  @@ -231,7 +234,8 @@
   
                   files = ds.getIncludedFiles();
                   for (int i = 0; i < files.length; i++) {
  -                    filesList.add(new File(srcDir.getAbsolutePath() + File.separator +
files[i]));
  +                    filesList.add(new File(srcDir.getAbsolutePath() 
  +                                           + File.separator + files[i]));
                   }
               }
               // deal with the filesets
  @@ -241,7 +245,8 @@
                   files = ds.getIncludedFiles();
                   File fromDir = fs.getDir(getProject());
                   for (int j = 0; j < files.length; j++) {
  -                    filesList.add(new File(fromDir.getAbsolutePath() + File.separator +
files[j]));
  +                    filesList.add(new File(fromDir.getAbsolutePath() 
  +                                           + File.separator + files[j]));
                   }
               }
   
  @@ -251,7 +256,7 @@
                   for (Iterator i = filesList.iterator(); i.hasNext();) {
                       File f = (File) i.next();
                       File new_file = new File(destDir.getAbsolutePath()
  -                        + File.separator + f.getName());
  +                                             + File.separator + f.getName());
                       if (new_file.exists()) {
                           filesToRemove.add(f);
                       }
  @@ -286,14 +291,12 @@
       protected void validateAttributes() throws BuildException {
           if (srcDir == null && filesets.size() == 0) {
               throw new BuildException("Specify at least one source "
  -                    + "- a srcDir or a fileset.");
  +                                     + "- a srcDir or a fileset.");
           }
   
           if (srcDir == null && destDir == null) {
               throw new BuildException("Specify the destDir, or the srcDir.");
           }
  -
  -
       }
   
   }
  
  
  
  1.9       +44 -36    ant/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
  
  Index: ImageTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ImageTest.java	9 Mar 2004 16:49:02 -0000	1.8
  +++ ImageTest.java	31 Mar 2004 09:07:22 -0000	1.9
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2000-2004 The Apache Software Foundation
  + * Copyright  2002-2004 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -36,7 +36,8 @@
    */
   public class ImageTest extends BuildFileTest {
   
  -    private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/image/";
  +    private final static String TASKDEFS_DIR = 
  +        "src/etc/testcases/taskdefs/optional/image/";
       private final static String LARGEIMAGE = "largeimage.jpg";
   
       public ImageTest(String name) {
  @@ -58,58 +59,65 @@
       }
   
       public void testSimpleScale(){
  -      expectLogContaining("testSimpleScale", "Processing File");
  -      File f = createRelativeFile( "/dest/" + LARGEIMAGE  );
  -          assertTrue(
  -              "Did not create "+f.getAbsolutePath(),
  -        f.exists() );
  +        expectLogContaining("testSimpleScale", "Processing File");
  +        File f = createRelativeFile("/dest/" + LARGEIMAGE);
  +        assertTrue(
  +                   "Did not create "+f.getAbsolutePath(),
  +                   f.exists());
   
       }
   
       public void testOverwriteTrue() {
  -      expectLogContaining("testSimpleScale", "Processing File");
  -      File f = createRelativeFile( "/dest/" + LARGEIMAGE  );
  -      long lastModified = f.lastModified();
  -       if (Os.isFamily("dos")) {
  -           try {
  -            Thread.sleep(2000);
  -           }
  -           catch (InterruptedException e) {}
  -       }
  -      expectLogContaining("testOverwriteTrue", "Processing File");
  -      f = createRelativeFile( "/dest/" + LARGEIMAGE  );
  -      long overwrittenLastModified = f.lastModified();
  -      assertTrue("File was not overwritten.",lastModified < overwrittenLastModified);
  +        expectLogContaining("testSimpleScale", "Processing File");
  +        File f = createRelativeFile("/dest/" + LARGEIMAGE);
  +        long lastModified = f.lastModified();
  +        if (Os.isFamily("dos")) {
  +            try {
  +                Thread.sleep(2000);
  +            }
  +            catch (InterruptedException e) {}
  +        }
  +        expectLogContaining("testOverwriteTrue", "Processing File");
  +        f = createRelativeFile("/dest/" + LARGEIMAGE);
  +        long overwrittenLastModified = f.lastModified();
  +        assertTrue("File was not overwritten.",
  +                   lastModified < overwrittenLastModified);
       }
   
       public void testOverwriteFalse() {
  -      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);
  +        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 void off_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);
  -      }
  +        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);
  +        }
       }
   
   
   
  -  protected File createRelativeFile( String filename ) {
  -        if (filename.equals( "." )) {
  +    protected File createRelativeFile(String filename) {
  +        if (filename.equals(".")) {
               return getProjectDir();
           }
           // else
  -        return new File( getProjectDir(), filename );
  +        return new File(getProjectDir(), filename);
       }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message