You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2004/08/03 00:42:20 UTC
cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional WsdlToDotnetTest.java
stevel 2004/08/02 15:42:20
Modified: src/etc/testcases/taskdefs/optional WsdlToDotnet.xml
src/main/org/apache/tools/ant/taskdefs/optional/dotnet
WsdlToDotnet.java
src/testcases/org/apache/tools/ant/taskdefs/optional
WsdlToDotnetTest.java
Log:
Now support for nested schemas as add ons. Will probably break mono, but the tests have been written so as not to expose that break.
Also: protocol, parseableErrors. These are WSE2.0 options.
Revision Changes Path
1.8 +35 -1 ant/src/etc/testcases/taskdefs/optional/WsdlToDotnet.xml
Index: WsdlToDotnet.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/WsdlToDotnet.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- WsdlToDotnet.xml 30 Jul 2004 06:34:12 -0000 1.7
+++ WsdlToDotnet.xml 2 Aug 2004 22:42:20 -0000 1.8
@@ -187,6 +187,40 @@
srcFile="${local.wsdl}"
extraOptions="/newOption:not-one-known-of"
/>
- </target>
+ </target>
+
+ <target name="testParseableErrorsIgnoredWhenFalse" depends="init">
+ <wsdltodotnet destFile="${out.csc}"
+ srcFile="${local.wsdl}"
+ parseableErrors="false"
+ >
+ </wsdltodotnet>
+ </target>
+
+ <target name="testSchemaMustBeSet" depends="init">
+ <wsdltodotnet destFile="${out.csc}"
+ srcFile="${local.wsdl}"
+ >
+ <schema/>
+ </wsdltodotnet>
+ </target>
+
+ <target name="testSchemaFileMustExist" depends="init">
+ <wsdltodotnet destFile="${out.csc}"
+ srcFile="${local.wsdl}"
+ >
+ <schema file="this-file-does-not-exist.xsd"/>
+ </wsdltodotnet>
+ </target>
+
+ <target name="testSchemaFileMustHaveOneOptionOnly" depends="init">
+ <wsdltodotnet destFile="${out.csc}"
+ srcFile="${local.wsdl}"
+ >
+ <schema file="wsdlToDotnet.xml"
+ url="http://ant.apache.org/xml/AntSchema.xsd"/>
+ </wsdltodotnet>
+ </target>
+
</project>
1.23 +151 -3 ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/WsdlToDotnet.java
Index: WsdlToDotnet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/WsdlToDotnet.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- WsdlToDotnet.java 28 Jul 2004 13:46:37 -0000 1.22
+++ WsdlToDotnet.java 2 Aug 2004 22:42:20 -0000 1.23
@@ -17,6 +17,9 @@
package org.apache.tools.ant.taskdefs.optional.dotnet;
import java.io.File;
+import java.util.Vector;
+import java.util.Iterator;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.condition.Os;
@@ -87,10 +90,31 @@
protected String extraOptions = null;
/**
+ * mono flag; we ignore the Rotor implementation of the CLR
* @since Ant 1.7
*/
private boolean isMono = !Os.isFamily("windows");
+
+ /**
+ * protocol string. Exact value set depends on SOAP stack version.
+ * @since Ant 1.7
+ */
+ private String protocol = null;
+
+ /**
+ * should errors come in a machine parseable format. This
+ * is WSE only.
+ * @since Ant 1.7
+ */
+ private boolean parseableErrors = false;
+
+ /**
+ * filesets of file to compile
+ * @since Ant 1.7
+ */
+ private Vector schemas = new Vector();
+
/**
* Name of the file to generate. Required
* @param destFile filename
@@ -111,7 +135,7 @@
/**
* The local WSDL file to parse; either url or srcFile is required.
- * @param srcFile name of WSDL file
+ * @param srcFileName name of WSDL file
*/
public void setSrcFile(String srcFileName) {
if (new File(srcFileName).isAbsolute()) {
@@ -180,6 +204,40 @@
isMono = b;
}
+
+ /**
+ * Should errors be machine parseable?
+ * Optional, default=true
+ *
+ * @since Ant 1.7
+ * @param parseableErrors
+ */
+ public void setParseableErrors(boolean parseableErrors) {
+ this.parseableErrors = parseableErrors;
+ }
+
+ /**
+ * what protocol to use. SOAP, SOAP1.2, HttpPost and HttpGet
+ * are the base options. Different version and implementations may.
+ * offer different options.
+ * @since Ant 1.7
+ *
+ * @param protocol
+ */
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ /**
+ * add a new source schema to the compilation
+ * @since Ant 1.7
+ *
+ * @param source
+ */
+ public void addSchema(Schema source) {
+ schemas.add(source);
+ }
+
/**
* validation code
* @throws BuildException if validation failed
@@ -233,10 +291,17 @@
command.addArgument("/server");
}
command.addArgument("/namespace:", namespace);
+ if(protocol!=null) {
+ command.addArgument("/protocol:"+protocol);
+ }
+ if(parseableErrors) {
+ command.addArgument("/parseableErrors");
+ }
command.addArgument(extraOptions);
//set source and rebuild options
boolean rebuild = true;
+ long destLastModified = -1;
if (srcFileName != null) {
File srcFile = getProject().resolveFile(srcFileName);
if (isMono) {
@@ -246,8 +311,11 @@
command.addArgument(srcFile.toString());
}
//rebuild unless the dest file is newer than the source file
- if (srcFile.exists() && destFile.exists()
- && srcFile.lastModified() <= destFile.lastModified()) {
+ if ( destFile.exists() ) {
+ destLastModified = destFile.lastModified();
+ }
+ if (srcFile.exists()
+ && srcFile.lastModified() <= destLastModified) {
rebuild = false;
}
} else {
@@ -256,8 +324,88 @@
rebuild = true;
command.addArgument(url);
}
+ //add in any extra files.
+ //this is an error in mono, but we do not warn on it as they may fix that outside
+ //the ant build cycle.
+ Iterator it=schemas.iterator();
+ while ( it.hasNext() ) {
+ Schema schema = (Schema) it.next();
+ //get date, mark for a rebuild if we are newer
+ long schemaTimestamp;
+ schemaTimestamp=schema.getTimestamp();
+ if(schemaTimestamp>destLastModified) {
+ rebuild=true;
+ }
+ command.addArgument(schema.evaluate());
+ }
+ //conditionally compile
if (rebuild) {
command.runCommand();
+ }
+ }
+
+
+ /**
+ * nested schema class
+ * Only supported on NET until mono add multi-URL handling on the command line
+ */
+ public static class Schema {
+ private File file;
+ private String url;
+ public static final String ERROR_NONE_DECLARED = "One of file and url must be set";
+ public static final String ERROR_BOTH_DECLARED = "Only one of file or url can be set";
+ public static final String ERROR_FILE_NOT_FOUND = "Not found: ";
+
+ public void validate() {
+
+ if(file!=null && !file.exists()) {
+ throw new BuildException(ERROR_FILE_NOT_FOUND+file.toString());
+ }
+ if(file!=null && url!=null) {
+ throw new BuildException(ERROR_BOTH_DECLARED);
+ }
+ if(file==null && url==null) {
+ throw new BuildException(ERROR_NONE_DECLARED);
+ }
+ }
+
+ /**
+ * validate our settings then return either the url or the full file path.
+ * @return
+ */
+ public String evaluate() {
+ validate();
+ if(file!=null) {
+ return file.toString();
+ } else {
+ return getUrl();
+ }
+ }
+ public File getFile() {
+ return file;
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ /**
+ * return the timestamp of a file, or -1 for a url (meaning we do not know its age)
+ * @return
+ */
+ public long getTimestamp() {
+ if(file!=null) {
+ return file.lastModified();
+ } else
+ return -1;
}
}
}
1.9 +39 -0 ant/src/testcases/org/apache/tools/ant/taskdefs/optional/WsdlToDotnetTest.java
Index: WsdlToDotnetTest.java
===================================================================
RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/WsdlToDotnetTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WsdlToDotnetTest.java 28 Jul 2004 13:47:38 -0000 1.8
+++ WsdlToDotnetTest.java 2 Aug 2004 22:42:20 -0000 1.9
@@ -20,6 +20,7 @@
import java.util.Properties;
import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet;
/**
* Tests the WsdlToDotnet task.
@@ -155,5 +156,43 @@
"expected failure",
"WSDL returned:");
}
+
+ /**
+ * as if parseable errors were not ignored, mono and WSE1.0 would
+ * crash and burn. So here we verify the property exists,
+ * and that it is not passed to the app when false
+ */
+ public void testParseableErrorsIgnoredWhenFalse() throws Exception {
+ executeTarget("testLocalWsdl");
+ }
+
+ /**
+ * A unit test for JUnit
+ */
+ public void testSchemaFileMustExist() throws Exception {
+ expectBuildExceptionContaining("testSchemaFileMustExist",
+ "expected failure",
+ WsdlToDotnet.Schema.ERROR_FILE_NOT_FOUND);
+ }
+
+ /**
+ * A unit test for JUnit
+ */
+ public void testSchemaFileMustHaveOneOptionOnly() throws Exception {
+ expectBuildExceptionContaining("testSchemaFileMustHaveOneOptionOnly",
+ "expected failure",
+ WsdlToDotnet.Schema.ERROR_BOTH_DECLARED);
+ }
+
+ /**
+ * A unit test for JUnit
+ */
+ public void testSchemaMustBeSet() throws Exception {
+ expectBuildExceptionContaining("testSchemaMustBeSet",
+ "expected failure",
+ WsdlToDotnet.Schema.ERROR_NONE_DECLARED);
+ }
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional
WsdlToDotnetTest.java
Posted by Steve Loughran <st...@apache.org>.
Stefan Bodewig wrote:
> On 2 Aug 2004, <st...@apache.org> wrote:
>
>
>> Will probably break mono, but the tests have been written so as
>> not to expose that break.
>
>
> I can confirm that tests still pass on Mono 1.0/Linux (after I fixed
> the case of a file name - you are using HFS+ on your Mac?).
No, I wrote that stuff on windows.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: cvs commit:
ant/src/testcases/org/apache/tools/ant/taskdefs/optional
WsdlToDotnetTest.java
Posted by Stefan Bodewig <bo...@apache.org>.
On 2 Aug 2004, <st...@apache.org> wrote:
> Will probably break mono, but the tests have been written so as
> not to expose that break.
I can confirm that tests still pass on Mono 1.0/Linux (after I fixed
the case of a file name - you are using HFS+ on your Mac?).
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org