Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 69292 invoked from network); 7 Sep 2003 09:40:57 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 7 Sep 2003 09:40:57 -0000 Received: (qmail 56786 invoked by uid 500); 7 Sep 2003 09:40:21 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 56672 invoked by uid 500); 7 Sep 2003 09:40:20 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 56650 invoked by uid 500); 7 Sep 2003 09:40:19 -0000 Received: (qmail 56641 invoked from network); 7 Sep 2003 09:40:19 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 7 Sep 2003 09:40:19 -0000 Received: (qmail 69228 invoked by uid 1694); 7 Sep 2003 09:40:40 -0000 Date: 7 Sep 2003 09:40:40 -0000 Message-ID: <20030907094040.69227.qmail@minotaur.apache.org> From: jhm@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional PropertyFileTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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