ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant ProjectTest.java
Date Fri, 07 Jan 2005 14:04:41 GMT
jkf         2005/01/07 06:04:41

  Modified:    src/testcases/org/apache/tools/ant/util FileUtilsTest.java
               src/testcases/org/apache/tools/ant ProjectTest.java
  Log:
  Adapted the FileUtils test to show behaviour based on os type.
  
  Revision  Changes    Path
  1.32      +73 -50    ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java
  
  Index: FileUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- FileUtilsTest.java	6 Jan 2005 12:05:07 -0000	1.31
  +++ FileUtilsTest.java	7 Jan 2005 14:04:41 -0000	1.32
  @@ -109,37 +109,37 @@
           assertEquals(File.separator,
                        FILE_UTILS.resolveFile(null, "\\").getPath());
   
  -        /*
  -         * throw in drive letters
  -         */
  -        String driveSpec = "C:";
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.resolveFile(null, driveSpec + "/").getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath());
  -        String driveSpecLower = "c:";
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath());
  -        /*
  -         * promised to eliminate consecutive slashes after drive letter.
  -         */
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath());
  -
  -        if (Os.isFamily("netware")) {
  +        if (Os.isFamily("dos")) {
  +            /*
  +             * throw in drive letters
  +             */
  +            String driveSpec = "C:";
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.resolveFile(null, driveSpec + "/").getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath());
  +            String driveSpecLower = "c:";
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath());
  +            /*
  +             * promised to eliminate consecutive slashes after drive letter.
  +             */
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath());
  +        } else if (Os.isFamily("netware")) {
               /*
                * throw in NetWare volume names
                */
  -            driveSpec = "SYS:";
  +            String driveSpec = "SYS:";
               assertEquals(driveSpec,
                            FILE_UTILS.resolveFile(null, driveSpec + "/").getPath());
               assertEquals(driveSpec,
                            FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath());
  -            driveSpecLower = "sys:";
  +            String driveSpecLower = "sys:";
               assertEquals(driveSpec,
                            FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath());
               assertEquals(driveSpec,
  @@ -151,6 +151,20 @@
                            FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath());
               assertEquals(driveSpec,
                            FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath());
  +        } else {
  +            /*
  +             * drive letters must be considered just normal filenames.
  +             */
  +            String driveSpec = "C:";
  +            assertEquals(driveSpec,
  +                         FILE_UTILS.resolveFile(null, driveSpec + "/").getPath());
  +            assertEquals(driveSpec,
  +                         FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath());
  +            String driveSpecLower = "c:";
  +            assertEquals(driveSpecLower,
  +                         FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath());
  +            assertEquals(driveSpecLower,
  +                         FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath());
           }
   
           /*
  @@ -191,41 +205,41 @@
           assertEquals(File.separator,
                        FILE_UTILS.normalize("\\").getPath());
   
  -        /*
  -         * throw in drive letters
  -         */
  -        String driveSpec = "C:";
  -        assertEquals(driveSpec,
  -                     FILE_UTILS.normalize(driveSpec).getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.normalize(driveSpec + "/").getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.normalize(driveSpec + "\\").getPath());
  -        String driveSpecLower = "c:";
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.normalize(driveSpecLower + "/").getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.normalize(driveSpecLower + "\\").getPath());
  -        /*
  -         * promised to eliminate consecutive slashes after drive letter.
  -         */
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.normalize(driveSpec + "/////").getPath());
  -        assertEquals(driveSpec + "\\",
  -                     FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath());
  -
  -        if (Os.isFamily("netware")) {
  +        if (Os.isFamily("dos")) {
  +            /*
  +             * throw in drive letters
  +             */
  +            String driveSpec = "C:";
  +            assertEquals(driveSpec,
  +                         FILE_UTILS.normalize(driveSpec).getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.normalize(driveSpec + "/").getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.normalize(driveSpec + "\\").getPath());
  +            String driveSpecLower = "c:";
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.normalize(driveSpecLower + "/").getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.normalize(driveSpecLower + "\\").getPath());
  +            /*
  +             * promised to eliminate consecutive slashes after drive letter.
  +             */
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.normalize(driveSpec + "/////").getPath());
  +            assertEquals(driveSpec + "\\",
  +                         FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath());
  +        } else if (Os.isFamily("netware")) {
               /*
                * throw in NetWare volume names
                */
  -            driveSpec = "SYS:";
  +            String driveSpec = "SYS:";
               assertEquals(driveSpec,
                            FILE_UTILS.normalize(driveSpec).getPath());
               assertEquals(driveSpec,
                            FILE_UTILS.normalize(driveSpec + "/").getPath());
               assertEquals(driveSpec,
                            FILE_UTILS.normalize(driveSpec + "\\").getPath());
  -            driveSpecLower = "sys:";
  +            String driveSpecLower = "sys:";
               assertEquals(driveSpec,
                            FILE_UTILS.normalize(driveSpecLower).getPath());
               assertEquals(driveSpec,
  @@ -241,6 +255,15 @@
                            FILE_UTILS.normalize(driveSpec + "/////").getPath());
               assertEquals(driveSpec,
                            FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath());
  +        } else {
  +            try {
  +                String driveSpec = "C:";
  +                assertEquals(driveSpec,
  +                             FILE_UTILS.normalize(driveSpec).getPath());
  +                fail("Expected failure, C: isn't an absolute path on other os's");
  +            } catch (BuildException e) {
  +                // Passed test 
  +            }
           }
   
           /*
  
  
  
  1.26      +38 -21    ant/src/testcases/org/apache/tools/ant/ProjectTest.java
  
  Index: ProjectTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/ProjectTest.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ProjectTest.java	9 Mar 2004 16:48:56 -0000	1.25
  +++ ProjectTest.java	7 Jan 2005 14:04:41 -0000	1.26
  @@ -20,6 +20,7 @@
   import org.apache.tools.ant.input.DefaultInputHandler;
   import org.apache.tools.ant.input.InputHandler;
   import org.apache.tools.ant.input.PropertyFileInputHandler;
  +import org.apache.tools.ant.taskdefs.condition.Os;
   import org.apache.tools.ant.types.*;
   import org.apache.tools.ant.util.JavaEnvUtils;
   
  @@ -74,27 +75,43 @@
           assertEquals(File.separator,
                        p.resolveFile("\\", null).getPath());
   
  -        /*
  -         * throw in drive letters
  -         */
  -        String driveSpec = "C:";
  -        assertEquals(driveSpec + "\\",
  -                     p.resolveFile(driveSpec + "/", null).getPath());
  -        assertEquals(driveSpec + "\\",
  -                     p.resolveFile(driveSpec + "\\", null).getPath());
  -        String driveSpecLower = "c:";
  -        assertEquals(driveSpec + "\\",
  -                     p.resolveFile(driveSpecLower + "/", null).getPath());
  -        assertEquals(driveSpec + "\\",
  -                     p.resolveFile(driveSpecLower + "\\", null).getPath());
  -        /*
  -         * promised to eliminate consecutive slashes after drive letter.
  -         */
  -        assertEquals(driveSpec + "\\",
  -                     p.resolveFile(driveSpec + "/////", null).getPath());
  -        assertEquals(driveSpec + "\\",
  -                     p.resolveFile(driveSpec + "\\\\\\\\\\\\", null).getPath());
  -
  +        if (Os.isFamily("netware") || Os.isFamily("dos")) {
  +            /*
  +             * throw in drive letters
  +             */
  +            String driveSpec = "C:";
  +            assertEquals(driveSpec + "\\",
  +                         p.resolveFile(driveSpec + "/", null).getPath());
  +            assertEquals(driveSpec + "\\",
  +                         p.resolveFile(driveSpec + "\\", null).getPath());
  +            String driveSpecLower = "c:";
  +            assertEquals(driveSpec + "\\",
  +                         p.resolveFile(driveSpecLower + "/", null).getPath());
  +            assertEquals(driveSpec + "\\",
  +                         p.resolveFile(driveSpecLower + "\\", null).getPath());
  +            /*
  +             * promised to eliminate consecutive slashes after drive letter.
  +             */
  +            assertEquals(driveSpec + "\\",
  +                         p.resolveFile(driveSpec + "/////", null).getPath());
  +            assertEquals(driveSpec + "\\",
  +                         p.resolveFile(driveSpec + "\\\\\\\\\\\\", null).getPath());
  +        } else {
  +            /*
  +             * drive letters are not used, just to be considered as normal
  +             * part of a name
  +             */
  +            String driveSpec = "C:";
  +            assertEquals(driveSpec,
  +                         p.resolveFile(driveSpec + "/", null).getPath());
  +            assertEquals(driveSpec,
  +                         p.resolveFile(driveSpec + "\\", null).getPath());
  +            String driveSpecLower = "c:";
  +            assertEquals(driveSpecLower,
  +                         p.resolveFile(driveSpecLower + "/", null).getPath());
  +            assertEquals(driveSpecLower,
  +                         p.resolveFile(driveSpecLower + "\\", null).getPath());
  +        }
           /*
            * Now test some relative file name magic.
            */
  
  
  

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


Mime
View raw message