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/taskdefs/optional PropertyFileTest.java
Date Sun, 07 Sep 2003 09:40:40 GMT
jhm         2003/09/07 02:40:40

  Modified:    src/testcases/org/apache/tools/ant/taskdefs/optional
                        PropertyFileTest.java
  Log:
  Checks that a property file is created when not present.
  
  Revision  Changes    Path
  1.9       +24 -15    ant/src/testcases/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
  
  Index: PropertyFileTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PropertyFileTest.java	11 Jul 2003 21:25:35 -0000	1.8
  +++ PropertyFileTest.java	7 Sep 2003 09:40:40 -0000	1.9
  @@ -96,6 +96,16 @@
           destroyTempFiles();
       }
   
  +    public void testNonExistingFile() {
  +        PropertyFile props = new PropertyFile();
  +        props.setProject( getProject() );
  +        File file = new File("this-file-does-not-exist.properties");
  +        props.setFile(file);
  +        assertFalse("Properties file exists before test.", file.exists());
  +        props.execute();
  +        assertTrue("Properties file does not exist after test.", file.exists());
  +        file.delete();
  +    }
   
       /**
        *  A unit test for JUnit- Excercises the propertyfile tasks ability to
  @@ -109,10 +119,10 @@
           assertEquals(null, beforeUpdate.getProperty(PHONE_KEY));
           assertEquals(null, beforeUpdate.getProperty(AGE_KEY));
           assertEquals(null, beforeUpdate.getProperty(DATE_KEY));
  -      
  +
           // ask ant to update the properties...
           executeTarget("update-existing-properties");
  -      
  +
           Properties afterUpdate = getTestProperties();
           assertEquals(NEW_FNAME, afterUpdate.getProperty(FNAME_KEY));
           assertEquals(NEW_LNAME, afterUpdate.getProperty(LNAME_KEY));
  @@ -155,7 +165,7 @@
           entry.setType(type);
   
           entry.setPattern("yyyy/MM/dd");
  -        
  +
           PropertyFile.Entry.Operation operation = new PropertyFile.Entry.Operation();
           operation.setValue("+");
           pf.execute();
  @@ -180,7 +190,7 @@
           testProps.put(LNAME_KEY, LNAME);
           testProps.put(EMAIL_KEY, EMAIL);
           testProps.put("existing.prop", "37");
  -      
  +
           FileOutputStream fos = new FileOutputStream(testPropsFilePath);
           testProps.store(fos, "defaults");
           fos.close();
  @@ -196,7 +206,7 @@
           buildProps.put(PHONE_KEY, NEW_PHONE);
           buildProps.put(AGE_KEY, NEW_AGE);
           buildProps.put(DATE_KEY, NEW_DATE);
  -      
  +
           FileOutputStream fos = new FileOutputStream(buildPropsFilePath);
           buildProps.store(fos, null);
           fos.close();
  @@ -216,12 +226,12 @@
           tempFile.delete();
           tempFile = null;
       }
  -   
   
   
  -    private static final String 
  +
  +    private static final String
           projectFilePath     = "src/etc/testcases/taskdefs/optional/propertyfile.xml",
  -      
  +
           testPropertyFile    = "propertyfile.test.properties",
           testPropertyFileKey = "test.propertyfile",
           testPropsFilePath   = "src/etc/testcases/taskdefs/optional/" + testPropertyFile,
  @@ -231,26 +241,25 @@
           valueDoesNotGetOverwrittenPropsFilePath   = "src/etc/testcases/taskdefs/optional/"
+ valueDoesNotGetOverwrittenPropertyFile,
   
           buildPropsFilePath  = "src/etc/testcases/taskdefs/optional/propertyfile.build.properties",
  -      
  +
           FNAME     = "Bruce",
           NEW_FNAME = "Clark",
           FNAME_KEY = "firstname",
  -      
  +
           LNAME     = "Banner",
           NEW_LNAME = "Kent",
           LNAME_KEY = "lastname",
  -      
  +
           EMAIL     = "incredible@hulk.com",
           NEW_EMAIL = "kc@superman.com",
           EMAIL_KEY = "email",
  -   
  +
           NEW_PHONE = "(520) 555-1212",
           PHONE_KEY = "phone",
  -      
  +
           NEW_AGE = "30",
           AGE_KEY = "age",
  -      
  +
           NEW_DATE = "2001/01/01 12:45",
           DATE_KEY = "date";
   }
  -
  
  
  

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


Mime
View raw message