X4O: Formatted plugins and maisdoc

This commit is contained in:
Willem Cazander 2025-11-07 21:48:59 +01:00
parent a61ce241e1
commit bd4a04a813
63 changed files with 1690 additions and 1589 deletions

View file

@ -32,7 +32,6 @@ import org.x4o.xml.lang.task.X4OLanguageTaskException;
import org.x4o.xml.lang.task.run.X4OTaskProperty;
import org.x4o.xml.lang.task.run.X4OTaskRunner;
/**
* AbstractX4OLanguageTask is base ant x4o language task executor.
*
@ -47,35 +46,37 @@ public class X4OTask extends Task {
private boolean verbose = false;
private boolean failonerror = true;
private List<X4OTaskProperty> taskProperties = null;
/**
* Constructs this ant x4o task.
*/
public X4OTask() {
taskProperties = new ArrayList<X4OTaskProperty>(15);
}
/**
* Adds the ant child x4oTaskProperty element.
* Adds the ant child x4oTaskProperty element.
*
* @param property
*/
public void addX4oTaskProperty(X4OTaskProperty property) {
taskProperties.add(property);
}
/**
* Executes the x4o eld schema task.
*
* @see org.apache.tools.ant.Task#execute()
*/
@Override
public void execute() throws BuildException {
try {
if (isVerbose()) {
log("Task location: "+getLocation());
log("X4O language name: "+getLanguageName());
log("X4O language version: "+getLanguageVersion());
log("Verbose: "+isVerbose());
log("Fail on error: "+isFailonerror());
log("Task location: " + getLocation());
log("X4O language name: " + getLanguageName());
log("X4O language version: " + getLanguageVersion());
log("Verbose: " + isVerbose());
log("Fail on error: " + isFailonerror());
}
executeLanguageTask();
} catch (BuildException e) {
@ -86,103 +87,103 @@ public class X4OTask extends Task {
}
}
}
private void executeLanguageTask() throws BuildException {
if (getLanguageName()==null) {
if (getLanguageName() == null) {
throw new BuildException("languageName attribute is not set.");
}
if (getLanguageName().length()==0) {
if (getLanguageName().length() == 0) {
throw new BuildException("languageName attribute is empty.");
}
if (getLanguageVersion()!=null && getLanguageVersion().length()==0) {
if (getLanguageVersion() != null && getLanguageVersion().length() == 0) {
throw new BuildException("languageVersion attribute is empty.");
}
if (getTaskId()==null) {
if (getTaskId() == null) {
throw new BuildException("taskId attribute is not set.");
}
if (getTaskId().length()==0) {
if (getTaskId().length() == 0) {
throw new BuildException("taskId attribute is empty.");
}
if (isVerbose()) {
log("Starting "+getTaskId());
log("Starting " + getTaskId());
}
long startTime = System.currentTimeMillis();
try {
X4OTaskRunner.runTask(getLanguageName(),getLanguageVersion(), getTaskId(), taskProperties);
X4OTaskRunner.runTask(getLanguageName(), getLanguageVersion(), getTaskId(), taskProperties);
} catch (X4OLanguageTaskException e) {
throw new BuildException(e);
}
long stopTime = System.currentTimeMillis();
String taskName = getLanguageName();
if (getLanguageVersion() != null) {
taskName += ":"+getLanguageVersion();
taskName += ":" + getLanguageVersion();
}
log("Done " + getTaskId() + " for " + taskName + " in " + (stopTime-startTime) + " ms.");
log("Done " + getTaskId() + " for " + taskName + " in " + (stopTime - startTime) + " ms.");
}
/**
* @return the languageName
*/
public String getLanguageName() {
return languageName;
}
/**
* @param languageName the languageName to set
*/
public void setLanguageName(String languageName) {
this.languageName = languageName;
}
/**
* @return the languageVersion
*/
public String getLanguageVersion() {
return languageVersion;
}
/**
* @param languageVersion the languageVersion to set
*/
public void setLanguageVersion(String languageVersion) {
this.languageVersion = languageVersion;
}
/**
* @return the verbose
*/
public boolean isVerbose() {
return verbose;
}
/**
* @param verbose the verbose to set
*/
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
/**
* @return the failonerror
*/
public boolean isFailonerror() {
return failonerror;
}
/**
* @param failonerror the failonerror to set
*/
public void setFailonerror(boolean failonerror) {
this.failonerror = failonerror;
}
/**
* @return the taskId
*/
public String getTaskId() {
return taskId;
}
/**
* @param taskId the taskId to set
*/

View file

@ -34,36 +34,36 @@ import org.apache.tools.ant.BuildFileTest;
* @version 1.0 Aug 23, 2012
*/
public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
public void setUp() {
configureProject("src/test/resources/junit/test-write-language-doc.xml");
}
public void testEldDocCel() {
executeTarget("test-elddoc-cel");
File testDir = new File("target/test-elddoc/cel");
int files = testDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
assertEquals("Should created more then two files", true, files > 2);
}
public void testEldDocEld() {
executeTarget("test-elddoc-eld");
File testDir = new File("target/test-elddoc/eld");
int files = testDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
///assertEquals("Message was logged but should not.", getLog(), "");
//expectLog("use.message", "attribute-text");
//assertLogContaining("Nested Element 1");
assertEquals("Should created more then two files", true, files > 2);
/// assertEquals("Message was logged but should not.", getLog(), "");
// expectLog("use.message", "attribute-text");
// assertLogContaining("Nested Element 1");
}
public void testEldDocEldCustom() {
executeTarget("test-elddoc-eld-custom");
File testDir = new File("target/test-elddoc/eld-custom");
int files = testDir.listFiles().length;
assertEquals("Should created more then two files", true, files>2);
assertEquals("Should created more then two files", true, files > 2);
}
public void testEldDocEldVerbose() {
executeTarget("test-elddoc-cel-verbose");
assertLogContaining("Verbose:");
@ -72,15 +72,19 @@ public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
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 testFailLanguage() {
expectBuildException("test-fail-language", "Should get exception id language is not set.");
}
public void testFailLanguageError() {
expectBuildException("test-fail-language-error", "Should get exception id language throws error.");
}

View file

@ -37,25 +37,25 @@ public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
public void setUp() {
configureProject("src/test/resources/junit/test-write-language-schema.xml");
}
public void testCelSchemaFull() {
executeTarget("test-cel-schema-full");
File testDir = new File("target/test-schemas/cel-full");
int files = testDir.listFiles().length;
assertEquals("Should created only 2 files", 2, files);
}
public void testCelSchemaSingle() {
executeTarget("test-cel-schema-single");
File testDir = new File("target/test-schemas/cel-single");
int files = testDir.listFiles().length;
assertEquals("Should created only one file", 1, files);
///assertEquals("Message was logged but should not.", getLog(), "");
//expectLog("use.message", "attribute-text");
//assertLogContaining("Nested Element 1");
/// assertEquals("Message was logged but should not.", getLog(), "");
// expectLog("use.message", "attribute-text");
// assertLogContaining("Nested Element 1");
}
public void testCelSchemaVerbose() {
executeTarget("test-cel-schema-verbose");
assertLogContaining("Verbose:");
@ -64,15 +64,19 @@ public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
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 testFailLanguage() {
expectBuildException("test-fail-language", "Should get exception id language is not set.");
}
public void testFailLanguageError() {
expectBuildException("test-fail-language-error", "Should get exception id language throws error.");
}