You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2002/07/04 09:38:40 UTC
cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant BuildFileTest.java IncludeTest.java
bodewig 2002/07/04 00:38:40
Modified: src/main/org/apache/tools/ant/helper Tag: ANT_15_BRANCH
ProjectHelperImpl.java
src/testcases/org/apache/tools/ant Tag: ANT_15_BRANCH
BuildFileTest.java IncludeTest.java
Added: src/etc/testcases/core/include/included_file_parse_error
Tag: ANT_15_BRANCH build.xml included_file.xml
src/etc/testcases/core/include/included_file_task_error Tag:
ANT_15_BRANCH build.xml included_file.xml
src/etc/testcases/core/include/including_file_parse_error
Tag: ANT_15_BRANCH build.xml included_file.xml
src/etc/testcases/core/include/including_file_task_error
Tag: ANT_15_BRANCH build.xml included_file.xml
Log:
Improve error messages when dealing with entity includes.
PR: 10456
Submitted by: Jason Brittain <ja...@collab.net>
Revision Changes Path
No revision
No revision
1.1.2.1 +17 -0 jakarta-ant/src/etc/testcases/core/include/included_file_parse_error/Attic/build.xml
1.1.2.1 +4 -0 jakarta-ant/src/etc/testcases/core/include/included_file_parse_error/Attic/included_file.xml
No revision
No revision
1.1.2.1 +17 -0 jakarta-ant/src/etc/testcases/core/include/included_file_task_error/Attic/build.xml
1.1.2.1 +4 -0 jakarta-ant/src/etc/testcases/core/include/included_file_task_error/Attic/included_file.xml
No revision
No revision
1.1.2.1 +19 -0 jakarta-ant/src/etc/testcases/core/include/including_file_parse_error/Attic/build.xml
1.1.2.1 +3 -0 jakarta-ant/src/etc/testcases/core/include/including_file_parse_error/Attic/included_file.xml
No revision
No revision
1.1.2.1 +18 -0 jakarta-ant/src/etc/testcases/core/include/including_file_task_error/Attic/build.xml
1.1.2.1 +3 -0 jakarta-ant/src/etc/testcases/core/include/including_file_task_error/Attic/included_file.xml
No revision
No revision
1.7.2.1 +2 -2 jakarta-ant/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
Index: ProjectHelperImpl.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- ProjectHelperImpl.java 23 Apr 2002 11:42:51 -0000 1.7
+++ ProjectHelperImpl.java 4 Jul 2002 07:38:40 -0000 1.7.2.1
@@ -155,7 +155,7 @@
parser.parse(inputSource);
} catch (SAXParseException exc) {
Location location =
- new Location(buildFile.toString(), exc.getLineNumber(),
+ new Location(exc.getSystemId(), exc.getLineNumber(),
exc.getColumnNumber());
Throwable t = exc.getException();
@@ -791,7 +791,7 @@
task.setTaskName(tag);
}
- task.setLocation(new Location(helperImpl.buildFile.toString(), helperImpl.locator.getLineNumber(),
+ task.setLocation(new Location(helperImpl.locator.getSystemId(), helperImpl.locator.getLineNumber(),
helperImpl.locator.getColumnNumber()));
helperImpl.configureId(task, attrs);
No revision
No revision
1.14.2.1 +1 -1 jakarta-ant/src/testcases/org/apache/tools/ant/BuildFileTest.java
Index: BuildFileTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/BuildFileTest.java,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- BuildFileTest.java 16 Apr 2002 15:14:59 -0000 1.14
+++ BuildFileTest.java 4 Jul 2002 07:38:40 -0000 1.14.2.1
@@ -221,7 +221,7 @@
*
* @param filename name of project file to run
*/
- protected void configureProject(String filename) {
+ protected void configureProject(String filename) throws BuildException {
logBuffer = new StringBuffer();
fullLogBuffer = new StringBuffer();
project = new Project();
1.3.2.1 +57 -1 jakarta-ant/src/testcases/org/apache/tools/ant/IncludeTest.java
Index: IncludeTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/IncludeTest.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- IncludeTest.java 14 Nov 2001 12:25:30 -0000 1.3
+++ IncludeTest.java 4 Jul 2002 07:38:40 -0000 1.3.2.1
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -91,4 +91,60 @@
configureProject("src/etc/testcases/core/include/frag#ment/relative.xml");
expectLog("test1", "from included entity");
}
+
+ public void testParseErrorInIncluding() {
+ try {
+ configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml");
+ fail("should have caused a parser exception");
+ } catch (BuildException e) {
+ assertEquals("Unexpected text \"extraneous_text\"",
+ e.getMessage());
+ assertTrue(e.getLocation().toString()
+ + " should end with build.xml:13: ",
+ e.getLocation().toString().endsWith("build.xml:13: "));
+ }
+ }
+
+ public void testTaskErrorInIncluding() {
+ configureProject("src/etc/testcases/core/include/including_file_task_error/build.xml");
+ try {
+ executeTarget("test");
+ } catch (BuildException e) {
+ assertTrue(e.getMessage()
+ + " should start with \'Warning: Could not find",
+ e.getMessage().startsWith("Warning: Could not find file "));
+ assertTrue(e.getLocation().toString()
+ + " should end with build.xml:14: ",
+ e.getLocation().toString().endsWith("build.xml:14: "));
+ }
+ }
+
+ public void testParseErrorInIncluded() {
+ try {
+ configureProject("src/etc/testcases/core/include/included_file_parse_error/build.xml");
+ fail("should have caused a parser exception");
+ } catch (BuildException e) {
+ assertEquals("Unexpected text \"e\"",
+ e.getMessage());
+ assertTrue(e.getLocation().toString()
+ + " should end with included_file.xml:2: ",
+ e.getLocation().toString()
+ .endsWith("included_file.xml:2: "));
+ }
+ }
+
+ public void testTaskErrorInIncluded() {
+ configureProject("src/etc/testcases/core/include/included_file_task_error/build.xml");
+ try {
+ executeTarget("test");
+ } catch (BuildException e) {
+ assertTrue(e.getMessage()
+ + " should start with \'Warning: Could not find",
+ e.getMessage().startsWith("Warning: Could not find file "));
+ assertTrue(e.getLocation().toString()
+ + " should end with included_file.xml:2: ",
+ e.getLocation().toString().endsWith("included_file.xml:2: "));
+ }
+ }
+
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>