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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue