Merged ant plugins to one.

This commit is contained in:
Willem Cazander 2013-04-08 21:44:16 +02:00
parent 179c0f3bfe
commit 37d249eb24
18 changed files with 288 additions and 448 deletions

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>x4o-plugin-ant</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,209 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin</artifactId>
<version>0.8.5-SNAPSHOT</version>
</parent>
<artifactId>x4o-plugin-ant</artifactId>
<name>x4o-plugin-ant</name>
<description>x4o-plugin-ant</description>
<dependencies>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-elddoc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>${ant.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId>
<version>${ant-testutil.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel</artifactId>
<version>${juel.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>${xerces.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
<configuration>
<siteDirectory>${project.basedir}/../../src/site-child</siteDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>update-schema-cel</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>update-schema-cel-ant</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask" classpathref="maven.plugin.classpath"/>
<writeLanguageSchema destdir="${coredir}/cel" language="cel"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-schema</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>update-schema-eld</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>update-schema-eld-ant</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask" classpathref="maven.plugin.classpath"/>
<writeLanguageSchema destdir="${coredir}/cel" language="cel"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-schema</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>site-elddoc</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>site-elddoc-ant</id>
<phase>pre-site</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../target/site/elddocs"/>
<mkdir dir="${coredir}/cel"/>
<mkdir dir="${coredir}/eld"/>
<mkdir dir="${coredir}/junit-test"/>
<mkdir dir="${coredir}/junit-swixml2"/>
<mkdir dir="${coredir}/junit-swixml3"/>
<taskdef name="writeLanguageDoc" classname="org.x4o.plugin.ant.X4OWriteLanguageDocTask" classpathref="maven.plugin.classpath"/>
<writeLanguageDoc destdir="${coredir}/cel" language="cel"/>
<writeLanguageDoc destdir="${coredir}/eld" language="eld"/>
<writeLanguageDoc destdir="${coredir}/junit-test" language="test"/>
<writeLanguageDoc destdir="${coredir}/junit-swixml2" language="swixml" version="2.0"/>
<writeLanguageDoc destdir="${coredir}/junit-swixml3" language="swixml"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-elddoc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel</artifactId>
<version>${juel.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View file

@ -0,0 +1,155 @@
/*
* Copyright (c) 2004-2012, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.plugin.ant;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
/**
* AbstractX4OLanguageTask is base ant x4o language task executor.
*
* @author Willem Cazander
* @version 1.0 Apr 8, 2013
*/
abstract public class AbstractX4OLanguageTask extends Task {
private String language = null;
private String destdir = null;
private boolean verbose = false;
private boolean failonerror = true;
/**
* 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:"+getLanguage());
log("Destination Dir:"+getDestdir());
log("Verbose:"+isVerbose());
log("Fail on error:"+isFailonerror());
}
executeLanguageTask();
} catch (BuildException e) {
if (isFailonerror()) {
throw e;
} else {
log(e.getMessage(), Project.MSG_WARN);
}
}
}
private void executeLanguageTask() throws BuildException {
if (getLanguage()==null) {
throw new BuildException("language attribute is not set.");
}
if (getDestdir()==null) {
throw new BuildException("basePath attribute is not set.");
}
if (getLanguage().length()==0) {
throw new BuildException("language attribute is empty.");
}
if (getDestdir().length()==0) {
throw new BuildException("basePath attribute is empty.");
}
File basePathFile = new File(getDestdir());
if (basePathFile.exists()==false) {
throw new BuildException("destdir does not exists: "+basePathFile);
}
if (isVerbose()) {
log("Starting "+getLanguageTaskName());
}
long startTime = System.currentTimeMillis();
executeLanguageTask(basePathFile);
long stopTime = System.currentTimeMillis();
log("Done "+getLanguageTaskName()+" in "+(stopTime-startTime)+" ms.");
}
abstract String getLanguageTaskName();
abstract void executeLanguageTask(File basePath) throws BuildException;
/**
* @return the language
*/
public String getLanguage() {
return language;
}
/**
* @param language the language to set
*/
public void setLanguage(String language) {
this.language = language;
}
/**
* @return the destdir
*/
public String getDestdir() {
return destdir;
}
/**
* @param destdir the destdir to set
*/
public void setDestdir(String destdir) {
this.destdir = destdir;
}
/**
* @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;
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2004-2012, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.plugin.ant;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.x4o.xml.eld.doc.X4OWriteLanguageDocExecutor;
import org.x4o.xml.element.ElementException;
/**
* X4OWriteDocTask creates schema for language.
*
* @author Willem Cazander
* @version 1.0 Aug 24, 2012
*/
public class X4OWriteLanguageDocTask extends AbstractX4OLanguageTask {
/**
* @see org.x4o.plugin.ant.AbstractX4OLanguageTask#getLanguageTaskName()
*/
@Override
String getLanguageTaskName() {
return "X4O Write language documentation";
}
/**
* Config and start eld writer
* @see org.x4o.plugin.ant.AbstractX4OLanguageTask#executeLanguageTask(java.io.File)
*/
@Override
void executeLanguageTask(File basePath) throws BuildException {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(basePath);
writer.setLanguage(getLanguage());
try {
writer.execute();
} catch (ElementException e) {
throw new BuildException(e);
}
}
}

View file

@ -0,0 +1,83 @@
/*
* Copyright (c) 2004-2012, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.plugin.ant;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.x4o.xml.eld.xsd.X4OWriteLanguageSchemaExecutor;
import org.x4o.xml.element.ElementException;
/**
* X4OWriteSchemaTask creates schema for language.
*
* @author Willem Cazander
* @version 1.0 Aug 23, 2012
*/
public class X4OWriteLanguageSchemaTask extends AbstractX4OLanguageTask {
private String nsuri = null;
/**
* @see org.x4o.plugin.ant.AbstractX4OLanguageTask#getLanguageTaskName()
*/
@Override
String getLanguageTaskName() {
return "X4O Write language schema";
}
/**
* Config and start schema writer
* @see org.x4o.plugin.ant.AbstractX4OLanguageTask#executeLanguageTask(java.io.File)
*/
@Override
void executeLanguageTask(File basePath) throws BuildException {
if (isVerbose() && getNsuri()!=null) {
log("Namespace uri: "+getNsuri());
}
X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor();
writer.setBasePath(basePath);
writer.setLanguage(getLanguage());
writer.setLanguageNamespaceUri(getNsuri()); // null is all namespaces
try {
writer.execute();
} catch (ElementException e) {
throw new BuildException(e);
}
}
/**
* @return the nsuri
*/
public String getNsuri() {
return nsuri;
}
/**
* @param nsuri the nsuri to set
*/
public void setNsuri(String nsuri) {
this.nsuri = nsuri;
}
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2004-2012, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* The ant plugin tasks.
*
* @since 1.0
*/
package org.x4o.plugin.ant;

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2004-2012, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.plugin.ant;
import java.io.File;
import org.apache.tools.ant.BuildFileTest;
/**
* X4OWriteDocTaskTest tests the doc ant task.
*
* @author Willem Cazander
* @version 1.0 Aug 23, 2012
*/
public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
public void setUp() {
configureProject("src/test/resources/tests/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);
}
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");
}
public void testEldDocEldVerbose() {
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 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

@ -0,0 +1,80 @@
/*
* Copyright (c) 2004-2012, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.plugin.ant;
import java.io.File;
import org.apache.tools.ant.BuildFileTest;
/**
* X4OWriteSchemaTaskTest tests the schema ant task.
*
* @author Willem Cazander
* @version 1.0 Aug 23, 2012
*/
public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
public void setUp() {
configureProject("src/test/resources/tests/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 3 files", 3, 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");
}
public void testCelSchemaVerbose() {
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 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

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2004-2012, Willem Cazander
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project name="ant-elddoc-task" basedir="../../../..">
<property name="test.dir" value="${basedir}/target/test-elddoc/"/>
<target name="init">
<taskdef name="writeLanguageDoc" classname="org.x4o.plugin.ant.X4OWriteLanguageDocTask"/>
<mkdir dir="${test.dir}"/>
<mkdir dir="${test.dir}/test"/>
</target>
<target name="test-elddoc-cel" depends="init">
<mkdir dir="${test.dir}/cel"/>
<writeLanguageDoc
destdir="${test.dir}/cel"
language="cel"
/>
</target>
<target name="test-elddoc-cel-verbose" depends="init">
<mkdir dir="${test.dir}/cel"/>
<writeLanguageDoc
verbose="true"
destdir="${test.dir}/cel"
language="cel"
/>
</target>
<target name="test-elddoc-eld" depends="init">
<mkdir dir="${test.dir}/eld"/>
<writeLanguageDoc
destdir="${test.dir}/eld"
language="cel"
/>
</target>
<target name="test-fail-all" depends="init">
<writeLanguageDoc/>
</target>
<target name="test-fail-destdir" depends="init">
<writeLanguageDoc language="cel"/>
</target>
<target name="test-fail-destdir-error" depends="init">
<writeLanguageDoc language="cel" destdir="${test.dir}/no-dir"/>
</target>
<target name="test-fail-language" depends="init">
<writeLanguageDoc destdir="${test.dir}/test"/>
</target>
<target name="test-fail-language-error" depends="init">
<writeLanguageDoc destdir="${test.dir}/test" language="cel-error"/>
</target>
</project>

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2004-2012, Willem Cazander
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project name="ant-schema-task" basedir="../../../..">
<property name="test.dir" value="${basedir}/target/test-schemas/"/>
<target name="init">
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask"/>
<mkdir dir="${test.dir}"/>
<mkdir dir="${test.dir}/test"/>
</target>
<target name="test-cel-schema-full" depends="init">
<mkdir dir="${test.dir}/cel-full"/>
<writeLanguageSchema
destdir="${test.dir}/cel-full"
language="eld"
/>
</target>
<target name="test-cel-schema-single" depends="init">
<mkdir dir="${test.dir}/cel-single"/>
<writeLanguageSchema
destdir="${test.dir}/cel-single"
language="cel"
nsuri="http://cel.x4o.org/xml/ns/cel-core"
/>
</target>
<target name="test-cel-schema-verbose" depends="init">
<mkdir dir="${test.dir}/cel-single"/>
<writeLanguageSchema
verbose="true"
destdir="${test.dir}/cel-single"
language="cel"
nsuri="http://cel.x4o.org/xml/ns/cel-core"
/>
</target>
<target name="test-fail-all" depends="init">
<writeLanguageSchema/>
</target>
<target name="test-fail-destdir" depends="init">
<writeLanguageSchema language="cel"/>
</target>
<target name="test-fail-destdir-error" depends="init">
<writeLanguageSchema language="cel" destdir="${test.dir}/no-dir"/>
</target>
<target name="test-fail-language" depends="init">
<writeLanguageSchema destdir="${test.dir}/test"/>
</target>
<target name="test-fail-language-error" depends="init">
<writeLanguageSchema destdir="${test.dir}/test" language="eld-error"/>
</target>
</project>