Converted to X4ODriver language base and prepared for write support.
This commit is contained in:
parent
6f4eca935e
commit
f2844c61f2
118 changed files with 4370 additions and 2411 deletions
|
|
@ -28,9 +28,9 @@ import java.io.File;
|
|||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.x4o.xml.core.X4OParserSupportException;
|
||||
import org.x4o.xml.core.config.X4OLanguageClassLoader;
|
||||
import org.x4o.xml.eld.doc.X4OLanguageEldDocWriter;
|
||||
|
||||
import org.x4o.xml.eld.doc.X4ODocWriterExecutor;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
/**
|
||||
* EldDocWriterTask creates schema for language.
|
||||
|
|
@ -40,7 +40,7 @@ import org.x4o.xml.eld.doc.X4OLanguageEldDocWriter;
|
|||
*/
|
||||
public class EldDocWriterTask extends Task {
|
||||
|
||||
private String supportclass = null;
|
||||
private String language = null;
|
||||
private String destdir = null;
|
||||
private boolean verbose = false;
|
||||
private boolean failonerror = true;
|
||||
|
|
@ -63,16 +63,16 @@ public class EldDocWriterTask extends Task {
|
|||
}
|
||||
|
||||
private void executeTask() throws BuildException {
|
||||
if (getSupportclass()==null) {
|
||||
throw new BuildException("supportclass attribute is not set.");
|
||||
if (getLanguage()==null) {
|
||||
throw new BuildException("language attribute is not set.");
|
||||
}
|
||||
if (getDestdir()==null) {
|
||||
throw new BuildException("basePath attribute is not set.");
|
||||
}
|
||||
if (isVerbose()) {
|
||||
log("Execute task from: "+getLocation());
|
||||
log("language:"+getLanguage());
|
||||
log("destdir:"+getDestdir());
|
||||
log("supportclass:"+getSupportclass());
|
||||
log("verbose:"+isVerbose());
|
||||
log("failonerror:"+isFailonerror());
|
||||
}
|
||||
|
|
@ -80,17 +80,11 @@ public class EldDocWriterTask extends Task {
|
|||
if (basePathFile.exists()==false) {
|
||||
throw new BuildException("destdir does not exists: "+basePathFile);
|
||||
}
|
||||
Class<?> parserSupport = null;
|
||||
try {
|
||||
parserSupport = X4OLanguageClassLoader.loadClass(getSupportclass());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new BuildException("Could not load class: "+getSupportclass(),e);
|
||||
}
|
||||
|
||||
// Config and start schema writer
|
||||
X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter();
|
||||
X4ODocWriterExecutor writer = new X4ODocWriterExecutor();
|
||||
writer.setBasePath(basePathFile);
|
||||
writer.setLanguageParserSupport(parserSupport);
|
||||
writer.setLanguage(getLanguage());
|
||||
try {
|
||||
if (isVerbose()) {
|
||||
log("Starting writing.");
|
||||
|
|
@ -99,23 +93,23 @@ public class EldDocWriterTask extends Task {
|
|||
writer.execute();
|
||||
long stopTime = System.currentTimeMillis();
|
||||
log("Done writing elddoc in "+(stopTime-startTime)+" ms.");
|
||||
} catch (X4OParserSupportException e) {
|
||||
} catch (ElementException e) {
|
||||
throw new BuildException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the supportclass
|
||||
* @return the language
|
||||
*/
|
||||
public String getSupportclass() {
|
||||
return supportclass;
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param supportclass the supportclass to set
|
||||
* @param language the language to set
|
||||
*/
|
||||
public void setSupportclass(String supportclass) {
|
||||
this.supportclass = supportclass;
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,27 +61,20 @@ public class EldDocWriterTaskTest extends BuildFileTest {
|
|||
executeTarget("test-elddoc-cel-verbose");
|
||||
assertLogContaining("verbose:");
|
||||
}
|
||||
|
||||
|
||||
public void testFailAllMissing() {
|
||||
expectBuildException("test-fail-all", "Should get exception with no attributes.");
|
||||
}
|
||||
public void testFailBasePath() {
|
||||
expectBuildException("test-fail-destdir", "Should get exception id destdir is not set.");
|
||||
}
|
||||
public void testFailBasePathError() {
|
||||
expectBuildException("test-fail-destdir-error", "Should get exception id destdir does not exists.");
|
||||
}
|
||||
public void testFailSupportClass() {
|
||||
expectBuildException("test-fail-supportclass", "Should get exception id supportclass is not set.");
|
||||
public void testFailLanguage() {
|
||||
expectBuildException("test-fail-language", "Should get exception id language is not set.");
|
||||
}
|
||||
public void testFailSupportClassError() {
|
||||
expectBuildException("test-fail-supportclass-error", "Should get exception id supportclass throws error.");
|
||||
}
|
||||
public void testFailAllMissing() {
|
||||
expectBuildException("test-fail-all", "Should get exception with no attributes.");
|
||||
}
|
||||
public void testFailClassError() {
|
||||
expectBuildException("test-fail-class-error", "No build exception while class is missing.");
|
||||
}
|
||||
public void testFailClassErrorNo() {
|
||||
executeTarget("test-fail-class-error-no");
|
||||
assertLogContaining("Could not load class:");
|
||||
public void testFailLanguageError() {
|
||||
expectBuildException("test-fail-language-error", "Should get exception id language throws error.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<mkdir dir="${test.dir}/cel"/>
|
||||
<eldDocWriter
|
||||
destdir="${test.dir}/cel"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
language="cel"
|
||||
/>
|
||||
</target>
|
||||
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
<eldDocWriter
|
||||
verbose="true"
|
||||
destdir="${test.dir}/cel"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
language="cel"
|
||||
/>
|
||||
</target>
|
||||
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
<mkdir dir="${test.dir}/eld"/>
|
||||
<eldDocWriter
|
||||
destdir="${test.dir}/eld"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
language="cel"
|
||||
/>
|
||||
</target>
|
||||
|
||||
|
|
@ -62,22 +62,16 @@
|
|||
<eldDocWriter/>
|
||||
</target>
|
||||
<target name="test-fail-destdir" depends="init">
|
||||
<eldDocWriter supportclass="org.x4o.xml.eld.EldParserSupportCore"/>
|
||||
<eldDocWriter language="cel"/>
|
||||
</target>
|
||||
<target name="test-fail-destdir-error" depends="init">
|
||||
<eldDocWriter supportclass="org.x4o.xml.eld.EldParserSupportCore" destdir="${test.dir}/no-dir"/>
|
||||
<eldDocWriter language="cel" destdir="${test.dir}/no-dir"/>
|
||||
</target>
|
||||
<target name="test-fail-supportclass" depends="init">
|
||||
<target name="test-fail-language" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test"/>
|
||||
</target>
|
||||
<target name="test-fail-supportclass-error" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" supportclass="org.x4o.xml.eld.EldErrorParserSupport"/>
|
||||
</target>
|
||||
<target name="test-fail-class-error" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" supportclass="non.excisting.clazz"/>
|
||||
</target>
|
||||
<target name="test-fail-class-error-no" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" supportclass="non.excisting.clazz" failonerror="false"/>
|
||||
<target name="test-fail-language-error" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" language="cel-error"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -28,9 +28,8 @@ import java.io.File;
|
|||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.x4o.xml.core.X4OParserSupportException;
|
||||
import org.x4o.xml.core.config.X4OLanguageClassLoader;
|
||||
import org.x4o.xml.eld.xsd.X4OLanguageEldXsdWriter;
|
||||
import org.x4o.xml.eld.xsd.X4OSchemaWriterExecutor;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
/**
|
||||
* SchemaWriterTask creates schema for language.
|
||||
|
|
@ -40,8 +39,8 @@ import org.x4o.xml.eld.xsd.X4OLanguageEldXsdWriter;
|
|||
*/
|
||||
public class EldXsdWriterTask extends Task {
|
||||
|
||||
private String language = null;
|
||||
private String nsuri = null;
|
||||
private String supportclass = null;
|
||||
private String destdir = null;
|
||||
private boolean verbose = false;
|
||||
private boolean failonerror = true;
|
||||
|
|
@ -64,35 +63,29 @@ public class EldXsdWriterTask extends Task {
|
|||
}
|
||||
|
||||
private void executeTask() throws BuildException {
|
||||
if (getSupportclass()==null) {
|
||||
throw new BuildException("supportclass attribute is not set.");
|
||||
if (getLanguage()==null) {
|
||||
throw new BuildException("langauge attribute is not set.");
|
||||
}
|
||||
if (getDestdir()==null) {
|
||||
throw new BuildException("destdir attribute is not set.");
|
||||
}
|
||||
if (isVerbose()) {
|
||||
log("Execute task from: "+getLocation());
|
||||
log("destdir:"+getDestdir());
|
||||
log("supportclass:"+getSupportclass());
|
||||
log("nsuri:"+getNsuri());
|
||||
log("verbose:"+isVerbose());
|
||||
log("failonerror:"+isFailonerror());
|
||||
log("language: "+getLanguage());
|
||||
log("destdir: "+getDestdir());
|
||||
log("nsuri: "+getNsuri());
|
||||
log("verbose: "+isVerbose());
|
||||
log("failonerror: "+isFailonerror());
|
||||
}
|
||||
File basePathFile = new File(getDestdir());
|
||||
if (basePathFile.exists()==false) {
|
||||
throw new BuildException("destdir does not exists: "+basePathFile);
|
||||
}
|
||||
Class<?> parserSupport = null;
|
||||
try {
|
||||
parserSupport = X4OLanguageClassLoader.loadClass(getSupportclass());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new BuildException("Could not load class: "+getSupportclass(),e);
|
||||
}
|
||||
|
||||
|
||||
// Config and start schema writer
|
||||
X4OLanguageEldXsdWriter writer = new X4OLanguageEldXsdWriter();
|
||||
X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor();
|
||||
writer.setBasePath(basePathFile);
|
||||
writer.setLanguageParserSupport(parserSupport);
|
||||
writer.setLanguage(getLanguage());
|
||||
writer.setLanguageNamespaceUri(getNsuri());
|
||||
try {
|
||||
if (isVerbose()) {
|
||||
|
|
@ -102,7 +95,11 @@ public class EldXsdWriterTask extends Task {
|
|||
writer.execute();
|
||||
long stopTime = System.currentTimeMillis();
|
||||
log("Done writing schema in "+(stopTime-startTime)+" ms.");
|
||||
} catch (X4OParserSupportException e) {
|
||||
} catch (ElementException e) {
|
||||
throw new BuildException(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new BuildException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new BuildException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -120,19 +117,19 @@ public class EldXsdWriterTask extends Task {
|
|||
public void setNsuri(String nsuri) {
|
||||
this.nsuri = nsuri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the supportclass
|
||||
* @return the language
|
||||
*/
|
||||
public String getSupportclass() {
|
||||
return supportclass;
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param supportclass the supportclass to set
|
||||
* @param language the language to set
|
||||
*/
|
||||
public void setSupportclass(String supportclass) {
|
||||
this.supportclass = supportclass;
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class EldXsdWriterTaskTest extends BuildFileTest {
|
|||
executeTarget("test-cel-schema-full");
|
||||
File testDir = new File("target/test-schemas/cel-full");
|
||||
int files = testDir.listFiles().length;
|
||||
assertEquals("Should created only two files", 2, files);
|
||||
assertEquals("Should created only 3 files", 3, files);
|
||||
}
|
||||
|
||||
public void testCelSchemaSingle() {
|
||||
|
|
@ -61,27 +61,20 @@ public class EldXsdWriterTaskTest extends BuildFileTest {
|
|||
executeTarget("test-cel-schema-verbose");
|
||||
assertLogContaining("verbose:");
|
||||
}
|
||||
|
||||
|
||||
public void testFailAllMissing() {
|
||||
expectBuildException("test-fail-all", "Should get exception if no attributes are set.");
|
||||
}
|
||||
public void testFailBasePath() {
|
||||
expectBuildException("test-fail-destdir", "Should get exception id destdir is not set.");
|
||||
}
|
||||
public void testFailBasePathError() {
|
||||
expectBuildException("test-fail-destdir-error", "Should get exception id destdir does not exists.");
|
||||
}
|
||||
public void testFailSupportClass() {
|
||||
expectBuildException("test-fail-supportclass", "Should get exception id supportclass is not set.");
|
||||
public void testFailLanguage() {
|
||||
expectBuildException("test-fail-language", "Should get exception id language is not set.");
|
||||
}
|
||||
public void testFailSupportClassError() {
|
||||
expectBuildException("test-fail-supportclass-error", "Should get exception id supportclass throws error.");
|
||||
}
|
||||
public void testFailAllMissing() {
|
||||
expectBuildException("test-fail-all", "Should get exception if no attributes are set.");
|
||||
}
|
||||
public void testFailClassError() {
|
||||
expectBuildException("test-fail-class-error", "No build exception while class is missing.");
|
||||
}
|
||||
public void testFailClassErrorNo() {
|
||||
executeTarget("test-fail-class-error-no");
|
||||
assertLogContaining("Could not load class:");
|
||||
public void testFailLanguageError() {
|
||||
expectBuildException("test-fail-language-error", "Should get exception id language throws error.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<mkdir dir="${test.dir}/cel-full"/>
|
||||
<eldXsdWriter
|
||||
destdir="${test.dir}/cel-full"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
language="eld"
|
||||
/>
|
||||
</target>
|
||||
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
<mkdir dir="${test.dir}/cel-single"/>
|
||||
<eldXsdWriter
|
||||
destdir="${test.dir}/cel-single"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
language="cel"
|
||||
nsuri="http://cel.x4o.org/xml/ns/cel-core"
|
||||
/>
|
||||
</target>
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
<eldXsdWriter
|
||||
verbose="true"
|
||||
destdir="${test.dir}/cel-single"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
language="cel"
|
||||
nsuri="http://cel.x4o.org/xml/ns/cel-core"
|
||||
/>
|
||||
</target>
|
||||
|
|
@ -64,22 +64,16 @@
|
|||
<eldXsdWriter/>
|
||||
</target>
|
||||
<target name="test-fail-destdir" depends="init">
|
||||
<eldXsdWriter supportclass="org.x4o.xml.eld.EldParserSupportCore"/>
|
||||
<eldXsdWriter language="cel"/>
|
||||
</target>
|
||||
<target name="test-fail-destdir-error" depends="init">
|
||||
<eldXsdWriter supportclass="org.x4o.xml.eld.EldParserSupportCore" destdir="${test.dir}/no-dir"/>
|
||||
<eldXsdWriter language="cel" destdir="${test.dir}/no-dir"/>
|
||||
</target>
|
||||
<target name="test-fail-supportclass" depends="init">
|
||||
<target name="test-fail-language" depends="init">
|
||||
<eldXsdWriter destdir="${test.dir}/test"/>
|
||||
</target>
|
||||
<target name="test-fail-supportclass-error" depends="init">
|
||||
<eldXsdWriter destdir="${test.dir}/test" supportclass="org.x4o.xml.eld.EldErrorParserSupport"/>
|
||||
</target>
|
||||
<target name="test-fail-class-error" depends="init">
|
||||
<eldXsdWriter destdir="${test.dir}/test" supportclass="non.excisting.clazz"/>
|
||||
</target>
|
||||
<target name="test-fail-class-error-no" depends="init">
|
||||
<eldXsdWriter destdir="${test.dir}/test" supportclass="non.excisting.clazz" failonerror="false"/>
|
||||
<target name="test-fail-language-error" depends="init">
|
||||
<eldXsdWriter destdir="${test.dir}/test" language="eld-error"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue