Author: tfischer
Date: Wed May 3 11:33:17 2006
New Revision: 399376
URL: http://svn.apache.org/viewcvs?rev=399376&view=rev
Log:
- implemented sql, sqlExec and doc tasks
- changed DataModelTask to be able to use it in more than one child classes
- some minor fixes
The test cases still need to be fixing, but in my opinion, the committed mojos
are quite functional.
Added:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DocumentationMojo.java
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlExecMojo.java
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlMojo.java
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java
Modified:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DataModelTaskMojo.java
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/OMMojo.java
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
Modified:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DataModelTaskMojo.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DataModelTaskMojo.java?rev=399376&r1=399375&r2=399376&view=diff
==============================================================================
---
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DataModelTaskMojo.java
(original)
+++
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DataModelTaskMojo.java
Wed May 3 11:33:17 2006
@@ -34,6 +34,12 @@
extends TexenTaskMojo
{
/**
+ * The context property for the database.
+ */
+ public static final String TARGET_DATABASE_CONTEXT_PROPERTY
+ = "targetDatabase";
+
+ /**
* The path to the directory where the schema files are located in.
*
* @parameter expression="${basedir}/src/main/torque/schema"
@@ -63,7 +69,7 @@
*
* @parameter
*/
- private String database;
+ private String targetDatabase;
/**
* The target package for the generated classes.
@@ -76,18 +82,26 @@
* The file containing the generation report, relative to
* <code>outputDir</code>.
*
- * @parameter
expression="report.${project.artifact.artifactId}".${goal}.generation"
* @required
*/
private String reportFile;
/**
- * determines if this task should run only if the schema has changed.
+ * Determines if this task should run only if the schema has changed.
*
* @parameter expression="true"
*/
private boolean runOnlyOnSchemaChange;
+
+ /**
+ * The path to the properties file containing the mapping
+ * sql file -> target database.
+ *
+ * @parameter
expression="${project.build.directory}/torque/sqldbmap.properties"
+ */
+ private String sqlDbMap;
+
/**
* Creates a new TorqueOMMojo object.
*/
@@ -97,6 +111,17 @@
}
/**
+ * Creates a new TorqueOMMojo object wrapping the passed
+ * TorqueDataModelTask.
+ *
+ * @param torqueDataModelTask the DataModelTask to be wrapped by this Mojo.
+ */
+ DataModelTaskMojo(TorqueDataModelTask torqueDataModelTask)
+ {
+ super(torqueDataModelTask);
+ }
+
+ /**
* Configures the Texen task which is wrapped by this mojo.
* In this implementation, the context properties, useClasspath,
* the output directory, the control template, the schema Fileset,
@@ -114,15 +139,18 @@
TorqueDataModelTask task
= (TorqueDataModelTask) super.getGeneratorTask();
- task.setControlTemplate("om/Control.vm");
+ task.setControlTemplate(getControlTemplate());
task.setOutputFile(reportFile);
- task.setControlTemplate("om/Control.vm");
-
- task.setTargetDatabase(database);
+ task.setTargetDatabase(targetDatabase);
task.setTargetPackage(getTargetPackage());
+
+ if (sqlDbMap != null)
+ {
+ task.setSqlDbMap(sqlDbMap);
+ }
{
FileSet fileSet = new FileSet();
@@ -132,7 +160,6 @@
task.addFileset(fileSet);
}
-
}
/**
@@ -212,25 +239,25 @@
}
/**
- * Returns the default database for the generated files.
+ * Returns the target database (e.g. mysql, oracle, ... )
+ * for the generated files.
*
- * @return the default database for the generated files.
+ * @return the target database for the generated files.
*/
- public String getDatabase()
+ public String getTargetDatabase()
{
- return database;
+ return targetDatabase;
}
/**
- * Sets the default database for the generated files.
- *
- * @param database the default database for the generated files.
+ * Sets the target database (e.g. mysql, oracle, ... )
+ * for the generated files.
*
- * @todo check what this setting does
+ * @param targetDatabase the target database for the generated files.
*/
- public void setDatabase(String database)
+ public void setTargetDatabase(String targetDatabase)
{
- this.database = database;
+ this.targetDatabase = targetDatabase;
}
/**
@@ -360,9 +387,29 @@
}
/**
- * Returns the name of the goal this mojo is providing.
+ * Returns the path to the mapping SQL Files -> database.
+ *
+ * @return the path to the mapping SQL Files -> database.
+ */
+ public String getSqlDbMap()
+ {
+ return sqlDbMap;
+ }
+
+ /**
+ * Sets the path to the mapping SQL Files -> database.
+ *
+ * @param sqlDbMap the absolute path to the mapping SQL Files -> database.
+ */
+ public void setSqlDbMap(String sqlDbMap)
+ {
+ this.sqlDbMap = sqlDbMap;
+ }
+
+ /**
+ * Returns the path to the control template.
*
- * @return the name of the goal this mojo is providing, not null.
+ * @return the path to the control template.
*/
- public abstract String getGoal();
+ protected abstract String getControlTemplate();
}
Added:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DocumentationMojo.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DocumentationMojo.java?rev=399376&view=auto
==============================================================================
---
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DocumentationMojo.java
(added)
+++
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/DocumentationMojo.java
Wed May 3 11:33:17 2006
@@ -0,0 +1,96 @@
+package org.apache.torque.mojo;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.torque.task.TorqueSQLTask;
+
+/**
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="[EMAIL PROTECTED]">Thomas Fischer</a>
+ *
+ * @goal documentation
+ * @phase generate-sources
+ */
+public class DocumentationMojo extends DataModelTaskMojo
+{
+ /** The context property for the output format. */
+ public static final String OUTPUT_FORMAT_CONTEXT_PROPERTY
+ = "outputFormat";
+
+ // this is here in order do trick the Mojo Description Extractor
+ // into setting the parameter outputDir, reportFile and
+ // contextPropertiesPath.
+ /**
+ * @parameter property="outputDir"
expression="${project.build.directory}/generated-docs/torque"
+ */
+ private String dummy;
+
+ /**
+ * @parameter property="reportFile"
expression="../../torque/report.${project.artifact.artifactId}.doc.generation"
+ */
+ private String dummy2;
+
+ /**
+ * @parameter property="contextPropertiesPath"
expression="${project.build.directory}/torque/context.doc.properties"
+ */
+ private String dummy3;
+
+ /**
+ * The format of the generated documentation. Can be either html or anakia.
+ *
+ * @parameter expression="html"
+ */
+ private String outputFormat;
+
+ /**
+ * Creates a new SQLMojo object.
+ */
+ public DocumentationMojo()
+ {
+ super(new TorqueSQLTask());
+ }
+
+ /**
+ * Sets the output format of the documentation (html or anakia)
+ *
+ * @param outputFormat the output format of the documentation.
+ */
+ public void setOutputFormat(String outputFormat)
+ {
+ this.outputFormat = outputFormat;
+ }
+
+ /**
+ * Returns the output format of the documentation (html or anakia)
+ *
+ * @return the output format of the documentation.
+ */
+ public String getOutputFormat()
+ {
+ return outputFormat;
+ }
+
+ /**
+ * Returns the context properties for the Texen task.
+ *
+ * @return The PropertiesConfiguration containing all context properties,
+ * not null.
+ */
+ protected PropertiesConfiguration getMojoContextProperties()
+ {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty(
+ OUTPUT_FORMAT_CONTEXT_PROPERTY,
+ getOutputFormat());
+ return configuration;
+ }
+
+ /**
+ * Returns the path to the control template.
+ *
+ * @return "sql/Control.vm"
+ */
+ protected String getControlTemplate()
+ {
+ return "doc/Control.vm";
+ }
+}
Modified:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/OMMojo.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/OMMojo.java?rev=399376&r1=399375&r2=399376&view=diff
==============================================================================
---
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/OMMojo.java
(original)
+++
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/OMMojo.java
Wed May 3 11:33:17 2006
@@ -36,14 +36,24 @@
public class OMMojo
extends DataModelTaskMojo
{
+ // this is here in order do trick the Mojo Description Extractor
+ // into setting the parameter outputDir, reportFile and
+ // contextPropertiesPath.
/**
- * The context property for the database.
- *
- * @todo check if this is used from the context properties.
+ * @parameter property="outputDir"
expression="${project.build.directory}/generated-sources/torque"
*/
- public static final String DATABASE_CONTEXT_PROPERTY
- = "database";
-
+ private String dummy;
+
+ /**
+ * @parameter property="reportFile"
expression="../../torque/report.${project.artifact.artifactId}.om.generation"
+ */
+ private String dummy2;
+
+ /**
+ * @parameter property="contextPropertiesPath"
expression="${project.build.directory}/torque/context.om.properties"
+ */
+ private String dummy3;
+
/**
* The context property for the target package.
*/
@@ -381,6 +391,7 @@
* @parameter expression="false"
*/
private boolean enableJava5Features;
+
/**
* Creates a new TorqueOMMojo object.
*/
@@ -420,6 +431,16 @@
}
/**
+ * Returns the path to the control template.
+ *
+ * @return "om/Control.vm"
+ */
+ protected String getControlTemplate()
+ {
+ return "om/Control.vm";
+ }
+
+ /**
* Returns the context properties for the Texen task.
*
* @return The PropertiesConfiguration containing all context properties,
@@ -432,8 +453,8 @@
{
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.addProperty(
- DATABASE_CONTEXT_PROPERTY,
- super.getDatabase());
+ TARGET_DATABASE_CONTEXT_PROPERTY,
+ super.getTargetDatabase());
configuration.addProperty(
TARGET_PACKAGE_CONTEXT_PROPERTY,
@@ -528,17 +549,6 @@
Boolean.toString(useManagers));
return configuration;
- }
-
- /**
- * returns the goal for this project.
- *
- * @return "om";
- * @see DataModelTaskMojo#getGoal()
- */
- public String getGoal()
- {
- return "om";
}
/**
Added:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlExecMojo.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlExecMojo.java?rev=399376&view=auto
==============================================================================
---
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlExecMojo.java
(added)
+++
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlExecMojo.java
Wed May 3 11:33:17 2006
@@ -0,0 +1,319 @@
+package org.apache.torque.mojo;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.tools.ant.Project;
+import org.apache.torque.task.TorqueSQLExec;
+import org.apache.torque.task.TorqueSQLExec.OnError;
+
+/**
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="[EMAIL PROTECTED]">Thomas Fischer</a>
+ *
+ * @goal sqlExec
+ * @phase generate-sources
+ */
+public class SqlExecMojo
+ extends AbstractMojo
+{
+ /**
+ * The ant task this mojo is wrapping.
+ */
+ private TorqueSQLExec antTask = new TorqueSQLExec();
+
+ /**
+ * The ant project the ant task is running in.
+ */
+ private Project antProject = new Project();
+
+ /**
+ * Autocommit flag. Default value is false
+ * @parameter expression="false"
+ */
+ private boolean autocommit = false;
+
+ /**
+ * Tells the Mojo what to do if an sql error occurs during execution.
+ * Can be either "continue", "stop" or "abort".
+ *
+ * @parameter expression="continue".
+ * @required
+ */
+ private String onError;
+
+ /**
+ * The fully qualified class name of the database driver.
+ * @parameter
+ * @required
+ */
+ private String driver = null;
+
+ /**
+ * The connect URL of the database.
+ * @parameter
+ * @required
+ */
+ private String url = null;
+
+ /**
+ * The user name to connect to the database.
+ * @parameter
+ * @required
+ */
+ private String user = null;
+
+ /**
+ * The password for the database user.
+ * @parameter
+ */
+ private String password = null;
+
+ /**
+ * The SQL Statement delimiter.
+ * @parameter expression=";"
+ */
+ private String delimiter = ";";
+
+ /**
+ * The path to the properties file containing the mapping
+ * sql file -> target database.
+ *
+ * @parameter
expression="${project.build.directory}/torque/sqldbmap.properties"
+ */
+ private String sqlDbMap;
+
+ /**
+ * The source directory where to find the SQL files.
+ *
+ * @parameter expression="${project.build.directory}/generated-sql/torque"
+ */
+ private String srcDir;
+
+ /**
+ * Creates and initializes a SqlExecMojo.
+ */
+ public SqlExecMojo()
+ {
+ antProject.init();
+ antTask.setProject(antProject);
+ }
+
+ /**
+ * Returns whether autocommit is turned on.
+ *
+ * @return true if autocommit is on, false otherwise.
+ */
+ public boolean isAutocommit()
+ {
+ return autocommit;
+ }
+
+ /**
+ * Sets whether autocommit is turned on.
+ * @param autocommit true to turn autocommit on, false to turn it off.
+ */
+ public void setAutocommit(boolean autocommit)
+ {
+ this.autocommit = autocommit;
+ }
+
+ /**
+ * The delimiter used to separate SQL commands.
+ *
+ * @return the delimiter used to separate SQL commands.
+ */
+ public String getDelimiter()
+ {
+ return delimiter;
+ }
+
+ /**
+ * Sets the delimiter used to separate SQL commands.
+ * @param delimiter the delimiter used to separate SQL commands.
+ */
+ public void setDelimiter(String delimiter)
+ {
+ this.delimiter = delimiter;
+ }
+
+ /**
+ * Returns the fully qualified class name of the database driver.
+ *
+ * @return the fully qualified class name of the database driver.
+ */
+ public String getDriver()
+ {
+ return driver;
+ }
+
+ /**
+ * Sets the fully qualified class name of the database driver.
+ *
+ * @param driver the fully qualified class name of the database driver.
+ */
+ public void setDriver(String driver)
+ {
+ this.driver = driver;
+ }
+
+ /**
+ * Returns the password of the database user.
+ * @return the password of the database user.
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Sets the password of the database user.
+ * @param password the password of the database user.
+ */
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /**
+ * Returns the connect URL to the database.
+ *
+ * @return the connect URL to the database.
+ */
+ public String getUrl()
+ {
+ return url;
+ }
+
+ /**
+ * Sets the connect URL to the database.
+ * @param url the connect URL to the database.
+ */
+ public void setUrl(String url)
+ {
+ this.url = url;
+ }
+
+ /**
+ * Returns the database user.
+ * @return the userId of the database user.
+ */
+ public String getUser()
+ {
+ return user;
+ }
+
+ /**
+ * Sets the database user.
+ * @param user the userId of the database user.
+ */
+ public void setUser(String user)
+ {
+ this.user = user;
+ }
+
+ /**
+ * Returns the path to the mapping SQL Files -> database.
+ *
+ * @return the path to the mapping SQL Files -> database.
+ */
+ public String getSqlDbMap()
+ {
+ return sqlDbMap;
+ }
+
+ /**
+ * Sets the path to the mapping SQL Files -> database.
+ *
+ * @param sqlDbMap the absolute path to the mapping SQL Files -> database.
+ */
+ public void setSqlDbMap(String sqlDbMap)
+ {
+ this.sqlDbMap = sqlDbMap;
+ }
+
+ /**
+ * Returns whether to procede if an sql error occurs
+ * during execution.
+ *
+ * @return onError what to do in case of an sql error, can be one of
+ * "continue", "stop" or "abort".
+ */
+ public String getOnError()
+ {
+ return onError;
+ }
+
+ /**
+ * Tells the task whether to procede if an sql error occurs
+ * during execution.
+ * Can be either "continue", "stop" or "abort".
+ *
+ * @param onError what to do in case of an sql error.
+ */
+ public void setOnError(String onError)
+ {
+ this.onError = onError;
+ }
+
+ /**
+ * Returns the path to the directory where the sql files can be found.
+ *
+ * @return the source directory where to find the SQL files.
+ */
+ public String getSrcDir()
+ {
+ return srcDir;
+ }
+
+ /**
+ * Sets the path to the directory where the sql files can be found.
+ *
+ * @param srcDir the source directory where to find the SQL files.
+ */
+ public void setSrcDir(String srcDir)
+ {
+ this.srcDir = srcDir;
+ }
+
+ /**
+ * Executes the goal of this mojo.
+ *
+ * @throws MojoExecutionException if the execution fails.
+ *
+ * @see Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException
+ {
+ configureTask();
+ antTask.execute();
+ }
+
+ /**
+ * Transfers the settings in this Mojo to the encapsulated ant task.
+ */
+ protected void configureTask()
+ {
+ antTask.setDelimiter(getDelimiter());
+ antTask.setAutocommit(isAutocommit());
+ antTask.setDriver(getDriver());
+ antTask.setUrl(getUrl());
+ antTask.setUserid(getUser());
+ antTask.setPassword(getPassword());
+ antTask.setSqlDbMap(getSqlDbMap());
+ antTask.setSrcDir(getSrcDir());
+ getLog().info("SQL src dir: " + getSrcDir());
+ antTask.setOnerror(getOnErrorAction());
+ }
+
+ /**
+ * Returns the onError setting as a OnError object.
+ * @return the onError setting as a OnError object, never null.
+ */
+ private OnError getOnErrorAction()
+ {
+ OnError onErrorAction = new OnError();
+ onErrorAction.setValue(onError);
+ return onErrorAction;
+ }
+}
Added:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlMojo.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlMojo.java?rev=399376&view=auto
==============================================================================
---
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlMojo.java
(added)
+++
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/SqlMojo.java
Wed May 3 11:33:17 2006
@@ -0,0 +1,122 @@
+package org.apache.torque.mojo;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.torque.task.TorqueSQLTask;
+
+/**
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="[EMAIL PROTECTED]">Thomas Fischer</a>
+ *
+ * @goal sql
+ * @phase generate-sources
+ */
+public class SqlMojo extends DataModelTaskMojo
+{
+ // this is here in order do trick the Mojo Description Extractor
+ // into setting the parameter outputDir, reportFile and
+ // contextPropertiesPath.
+ /**
+ * @parameter property="outputDir"
expression="${project.build.directory}/generated-sql/torque"
+ */
+ private String dummy;
+
+ /**
+ * @parameter property="reportFile"
expression="../../torque/report.${project.artifact.artifactId}.sql.generation"
+ */
+ private String dummy2;
+
+ /**
+ * @parameter property="contextPropertiesPath"
expression="${project.build.directory}/torque/context.sql.properties"
+ */
+ private String dummy3;
+
+ /**
+ * The suffix of the generated sql files.
+ * @parameter expression=""
+ */
+ private String suffix;
+
+ /**
+ * The path to the xml schema file that defines the id-table, used
+ * by the idbroker method.
+ * @parameter expression=""
+ */
+ private String idTableXmlFile;
+
+ /**
+ * Creates a new SQLMojo object.
+ */
+ public SqlMojo()
+ {
+ super(new TorqueSQLTask());
+ }
+
+ /**
+ * Sets the suffix of the generated sql files.
+ *
+ * @param suffix the suffix of the generated sql files.
+ */
+ public void setSuffix(String suffix)
+ {
+ this.suffix = suffix;
+ }
+
+ /**
+ * Returns the suffix of the generated sql files.
+ *
+ * @return the suffix of the generated sql files.
+ */
+ public String getSuffix()
+ {
+ return suffix;
+ }
+
+ /**
+ * Set the path to the xml schema file that defines the id-table, used
+ * by the idbroker method.
+ *
+ * @param idXmlFile xml schema file
+ */
+ public void setIdTableXmlFile(String idXmlFile)
+ {
+ idTableXmlFile = idXmlFile;
+ }
+
+ /**
+ * Gets the id-table xml schema file path.
+ *
+ * @return Path to file.
+ */
+ public String getIdTableXMLFile()
+ {
+ return idTableXmlFile;
+ }
+
+ /**
+ * Returns the context properties for the Texen task.
+ *
+ * @return The PropertiesConfiguration containing all context properties,
+ * not null.
+ *
+ * @todo add all om properties.
+ * @todo add a way to add custom properties.
+ */
+ protected PropertiesConfiguration getMojoContextProperties()
+ {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty(
+ TARGET_DATABASE_CONTEXT_PROPERTY,
+ super.getTargetDatabase());
+ return configuration;
+ }
+
+ /**
+ * Returns the path to the control template.
+ *
+ * @return "sql/Control.vm"
+ */
+ protected String getControlTemplate()
+ {
+ return "sql/base/Control.vm";
+ }
+}
Modified:
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java?rev=399376&r1=399375&r2=399376&view=diff
==============================================================================
---
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
(original)
+++
db/torque/trunks/maven2-plugin/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
Wed May 3 11:33:17 2006
@@ -43,7 +43,6 @@
/**
* The directory where Torque output is written to.
*
- * @parameter
expression="${project.build.directory}/generated-sources/torque"
* @required
*/
private String outputDir;
@@ -74,7 +73,6 @@
/**
* The path to the generated context property file.
*
- * @parameter
expression="${project.build.directory}/torque/context.properties"
* @required
*/
private String contextPropertiesPath;
Modified:
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java?rev=399376&r1=399375&r2=399376&view=diff
==============================================================================
---
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
(original)
+++
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
Wed May 3 11:33:17 2006
@@ -77,7 +77,7 @@
instance.setContextPropertiesPath(
mavenProject.getBuild().getDirectory()
- + "/torque/context.properties");
+ + "/torque/context.om.properties");
instance.setSchemaDir(
mavenProject.getBasedir() + "/src/main/torque/schema");
@@ -94,11 +94,10 @@
instance.setSchemaExcludes("id-table-schema.xml");
- instance.setReportFile("torque."
+ instance.setReportFile("../../torque/torque."
+ mavenProject.getArtifact().getArtifactId()
+ "."
- + instance.getGoal()
- + ".generation");
+ + "om.generation");
instance.execute();
Added:
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java
URL:
http://svn.apache.org/viewcvs/db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java?rev=399376&view=auto
==============================================================================
---
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java
(added)
+++
db/torque/trunks/maven2-plugin/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java
Wed May 3 11:33:17 2006
@@ -0,0 +1,124 @@
+package org.apache.torque.mojo;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.codehaus.plexus.PlexusTestCase;
+
+
+/**
+ * Tests the TorqueOMMojo
+ *
+ * @author Rapha�l Pi�roni (rafale_at_codehaus.org)
+ */
+public class TorqueSQLMojoTest
+ extends PlexusTestCase
+{
+ /**
+ * Test of execute method of class org.apache.torque.mojo.TorqueOMMojo;.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testExecute()
+ throws Exception
+ {
+ System.out.println ("execute");
+
+ MavenProjectBuilder builder
+ = (MavenProjectBuilder) lookup(MavenProjectBuilder.ROLE);
+
+ ArtifactRepositoryLayout localRepositoryLayout
+ = (ArtifactRepositoryLayout) lookup(
+ ArtifactRepositoryLayout.ROLE,
+ "default");
+
+ ArtifactRepository localRepository
+ = new DefaultArtifactRepository(
+ "local",
+ "file://" + getBasedir() + File.separator
+ + "target/test-classes/repository",
+ localRepositoryLayout);
+
+ MavenProject mavenProject = builder.buildWithDependencies(
+ new File(
+ getBasedir(),
+ "target/test-classes/projects/TorqueOMMojoTest/pom.xml"),
+ localRepository,
+ null);
+
+ SqlMojo instance = new SqlMojo();
+
+ instance.setProject(mavenProject);
+
+ instance.setOutputDir(
+ mavenProject.getBuild().getDirectory()
+ + "/generated-sql/torque");
+
+ instance.setContextPropertiesPath(
+ mavenProject.getBuild().getDirectory()
+ + "/torque/context.sql.properties");
+
+ instance.setSchemaDir(
+ mavenProject.getBasedir() + "/src/main/torque/schema");
+
+ instance.setUseClasspath(true);
+
+ instance.setTargetDatabase("postgresql");
+
+ instance.setSqlDbMap(mavenProject.getBuild().getDirectory()
+ +"/torque/sqldbmap.properties");
+
+ instance.setSchemaIncludes("*schema.xml");
+
+ instance.setReportFile("../../torque/torque."
+ + mavenProject.getArtifact().getArtifactId()
+ + "."
+ + "sql.generation");
+
+ instance.execute();
+
+ String generatedSqlDir
+ = "generated-sql/torque/";
+
+ assertTrue(
+ "test-TorqueOMMojoTest-schema.sql must exist",
+ new File(
+ mavenProject.getBuild().getDirectory(),
+ generatedSqlDir + "test-TorqueOMMojoTest-schema.sql")
+ .exists());
+
+ assertTrue(
+ "id-table-schema.sql must exist",
+ new File(
+ mavenProject.getBuild().getDirectory(),
+ generatedSqlDir + "id-table-schema.sql")
+ .exists());
+
+ assertTrue(
+ "sqldbmap.properties must exist",
+ new File(
+ mavenProject.getBuild().getDirectory(),
+ "torque/sqldbmap.properties")
+ .exists());
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]