db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r473817 [3/3] - in /db/torque: maven-plugin/trunk/ maven-plugin/trunk/src/plugin-resources/templates/ maven-plugin/trunk/xdocs/ maven2-plugin/trunk/ maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/ maven2-plugin/trunk/src/test/java...
Date Sat, 11 Nov 2006 22:32:43 GMT
Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java Sat Nov 11 14:32:42 2006
@@ -1,149 +1,152 @@
-package org.apache.torque.mojo;
-
-/*
- * Copyright 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 org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.torque.task.TorqueSQLTask;
-
-/**
- * Generates SQL for creating the database from the schema.xml files.
- *
- * @author Raphael Pieroni (rafale_at_codehaus.org)
- * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
- *
- * @goal sql
- * @phase generate-sources
- */
-public class SqlMojo extends DataModelTaskMojo
-{
-    // The following three dummies trick the Mojo Description Extractor
-    // into setting the correct default values for
-    // outputDir, reportFile and contextPropertiesPath
-    /**
-     * The directory in which the SQL will be generated.
-     *
-     * @parameter property="outputDir"
-     *            expression="${project.build.directory}/generated-sql/torque"
-     */
-    private String dummy;
-
-    /**
-     * The location where the report file will be generated.
-     *
-     * @parameter property="reportFile"
-     *            expression="../../torque/report.${project.artifact.artifactId}.sql.generation"
-     */
-    private String dummy2;
-
-    /**
-     * The location where the context property file for velocity will be
-     * generated.
-     *
-     * @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.
-     */
-    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";
-    }
-}
+package org.apache.torque.mojo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.torque.task.TorqueSQLTask;
+
+/**
+ * Generates SQL for creating the database from the schema.xml files.
+ *
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
+ *
+ * @goal sql
+ * @phase generate-sources
+ */
+public class SqlMojo extends DataModelTaskMojo
+{
+    // The following three dummies trick the Mojo Description Extractor
+    // into setting the correct default values for
+    // outputDir, reportFile and contextPropertiesPath
+    /**
+     * The directory in which the SQL will be generated.
+     *
+     * @parameter property="outputDir"
+     *            expression="${project.build.directory}/generated-sql/torque"
+     */
+    private String dummy;
+
+    /**
+     * The location where the report file will be generated.
+     *
+     * @parameter property="reportFile"
+     *            expression="../../torque/report.${project.artifact.artifactId}.sql.generation"
+     */
+    private String dummy2;
+
+    /**
+     * The location where the context property file for velocity will be
+     * generated.
+     *
+     * @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.
+     */
+    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/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java Sat Nov 11 14:32:42 2006
@@ -1,367 +1,370 @@
-package org.apache.torque.mojo;
-
-/*
- * Copyright 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 java.util.Iterator;
-import java.util.Map;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.FileConfiguration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.tools.ant.Project;
-import org.apache.velocity.texen.ant.TexenTask;
-
-
-/**
- * The base Class for all Mojos wrapping Texen Tasks.
- *
- * @author Rapha�l Pi�roni (rafale_at_codehaus.org)
- * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
- */
-public abstract class TexenTaskMojo
-    extends AbstractMojo
-{
-    /**
-     * The directory where the generator output is written to.
-     *
-     * @required
-     */
-    private String outputDir;
-
-    /**
-     * The base path where the templates are read from, if they are not read
-     * from the classpath.
-     *
-     * @parameter expression="${basedir}/src/main/torque/templates"
-     */
-    private String templatePath;
-
-    /**
-     * Whether the templates should be loaded from the classpath.
-     *
-     * @parameter expression="true"
-     */
-    private boolean useClasspath;
-
-    /**
-     * A map where all user-defined context properties can be set.
-     * Overrides all other mojo configuration settings which are mapped
-     * to context properties.
-     *
-     * @parameter
-     */
-    private Map userContextProperties;
-
-    /**
-     * The path to the generated context property file.
-     *
-     * @required
-     */
-    private String contextPropertiesPath;
-
-    /**
-     * The Maven project this plugin runs in.
-     *
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
-     */
-    private MavenProject project;
-
-    /**
-     * The generator task to be executed by this mojo.
-     */
-    private TexenTask generatorTask;
-
-    /**
-     * The ant project for the generator task.
-     */
-    private Project antProject;
-
-    /**
-     * Creates a new instance of AbstractTorqueMojo.
-     *
-     * @throws IllegalArgumentException if generatorTask is null.
-     */
-    public TexenTaskMojo(TexenTask generatorTask)
-    {
-        if (generatorTask == null)
-        {
-            throw new IllegalArgumentException("generatorTask is null");
-        }
-
-        // because the Texen Task needs the ant project to load its
-        // files, we need to attach one to the Texen task
-        antProject = new Project();
-        antProject.init();
-        generatorTask.setProject(antProject);
-
-        this.generatorTask = generatorTask;
-    }
-
-    /**
-     * Sets the maven project.
-     *
-     * @param project the maven project where this plugin runs in.
-     */
-    public void setProject(MavenProject project)
-    {
-        this.project = project;
-    }
-
-    /**
-     * Returns the maven project.
-     *
-     * @return The maven project where this plugin runs in.
-     */
-    public MavenProject getProject()
-    {
-        return project;
-    }
-
-    /**
-     * Returns the ant project.
-     *
-     * @return The ant project assigned to the generator task.
-     */
-    protected Project getAntProject()
-    {
-        return antProject;
-    }
-
-    /**
-     * Sets the path to Torque's output directory.
-     *
-     * @param outputDir the path to Torque's output directory.
-     */
-    public void setOutputDir(String outputDir)
-    {
-        this.outputDir = outputDir;
-    }
-
-    /**
-     * Returns the path to Torque's output directory.
-     *
-     * @return the path to Torque's output directory. Not null if
-     *         initialized correctly.
-     */
-    public String getOutputDir()
-    {
-        return this.outputDir;
-    }
-
-    /**
-     * Sets the path to Torque's templates, if the classpath is not used
-     * to load the templates.
-     *
-     * @param templatePath the path to Torque's templates.
-     */
-    public void setTemplatePath(String templatePath)
-    {
-        this.templatePath = templatePath;
-    }
-
-    /**
-     * Returns the path to Torque's templates, if the classpath is not used
-     * to load the templates.
-     *
-     * @return the path to Torque's templates.
-     */
-    public String getTemplatePath()
-    {
-        return this.templatePath;
-    }
-
-    /**
-     * Sets whether the classpath should be used to locate the templates.
-     *
-     * @param templatePath the path to Torque's templates.
-     */
-    public void setUseClasspath(boolean useClasspath)
-    {
-        this.useClasspath = useClasspath;
-    }
-
-    /**
-     * Returns whether the classpath is used to locate the templates.
-     *
-     * @return true if the classpath is used to locate the templates,
-     *         false otherwise
-     */
-    public boolean getUseClasspath()
-    {
-        return this.useClasspath;
-    }
-
-    /**
-     * Sets the path to the generated property file used as Texen's context
-     * properties.
-     *
-     * @param generatedPropertyFilePath the path to the generated context
-     *        properties file.
-     */
-    public void setContextPropertiesPath(String contextPropertiesPath)
-    {
-        this.contextPropertiesPath = contextPropertiesPath;
-    }
-
-    /**
-     * Returns the path to the generated property file used as Texen's context
-     * properties.
-     *
-     * @return the path to the generated context properties file.
-     */
-    public String getContextPropertiesPath()
-    {
-        return this.contextPropertiesPath;
-    }
-
-    /**
-     * Sets the map which defines user-defined context properties.
-     * The settings override all other mojo configuration settings
-     * which are mapped to context properties.
-     *
-     * @param contextProperties the user-defined context properties.
-     */
-    public void setUserContextProperties(Map userContextProperties)
-    {
-        this.userContextProperties = userContextProperties;
-    }
-
-    /**
-     * Returns the map which defines user-defined context properties.
-     *
-     * @return the map containing user-defined context properties,
-     *         or null if not set.
-     */
-    public Map getUserContextProperties()
-    {
-        return userContextProperties;
-    }
-
-    /**
-     * returns the generator Task for this mojo.
-     *
-     * @return the generator Task, not null.
-     */
-    protected TexenTask getGeneratorTask()
-    {
-        return generatorTask;
-    }
-
-    /**
-     * Generates the context properties file for Texen.
-     * The file is written to the path contextPropertiesPath.
-     *
-     * @throws MojoExecutionException if an error occurs.
-     */
-    protected void generateContextProperties()
-            throws MojoExecutionException
-    {
-        try
-        {
-            FileConfiguration configuration = getMojoContextProperties();
-            if (userContextProperties != null)
-            {
-                for (Iterator contextPropertyIt
-                        = userContextProperties.entrySet().iterator();
-                        contextPropertyIt.hasNext();)
-                {
-                    Map.Entry entry = (Map.Entry) contextPropertyIt.next();
-                    configuration.addProperty(
-                            entry.getKey().toString(),
-                            entry.getValue().toString());
-                }
-            }
-            configuration.save(contextPropertiesPath);
-        }
-        catch (ConfigurationException e)
-        {
-            getLog().error("Error writing temporary context properties: "
-                    + e.getMessage());
-            throw new MojoExecutionException(e.getMessage());
-        }
-    }
-
-    /**
-     * Configures the Texen task which is wrapped by this mojo.
-     * In this implementation, the context properties, useClasspath
-     * and the output directory are set. If more parameters need to be set,
-     * this method shouldb be overwritten in subclasses.
-     *
-     * @throws MojoExecutionException if an error occurs when setting the Tasks
-     *         properties.
-     */
-    protected void configureTask()
-            throws MojoExecutionException
-    {
-        generatorTask.setContextProperties(contextPropertiesPath);
-
-        generatorTask.setUseClasspath(useClasspath);
-
-        if (templatePath != null)
-        {
-            try
-            {
-                generatorTask.setTemplatePath(templatePath);
-            }
-            catch (Exception e)
-            {
-                getLog().error("Error setting template path: "
-                        + e.getMessage());
-                throw new MojoExecutionException(e.getMessage());
-            }
-        }
-
-        {
-            File outputDirectory = new File(outputDir);
-            getLog().debug("generating torque java sources into: "
-                + outputDirectory.getAbsolutePath());
-            outputDirectory.mkdirs();
-            generatorTask.setOutputDirectory(outputDirectory);
-        }
-    }
-
-    /**
-     * Executes the wrapped Texen task. Before this is done, the context
-     * properties file is generated and the Texen task is configured.
-     *
-     * @throws MojoExecutionException if an error occurs during execution.
-     *
-     * @see org.apache.maven.plugin.Mojo#execute()
-     */
-    public void execute() throws MojoExecutionException
-    {
-        generateContextProperties();
-        configureTask();
-        generatorTask.execute();
-    }
-
-    /**
-     * Returns the context properties for the Texen task which are defined
-     * in the configuration of the child mojo.
-     * This method needs to be overwritten in subclasses.
-     *
-     * @return The PropertiesConfiguration containing all context properties,
-     *         not null.
-     */
-    protected abstract PropertiesConfiguration getMojoContextProperties();
-}
+package org.apache.torque.mojo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.FileConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.tools.ant.Project;
+import org.apache.velocity.texen.ant.TexenTask;
+
+
+/**
+ * The base Class for all Mojos wrapping Texen Tasks.
+ *
+ * @author Rapha�l Pi�roni (rafale_at_codehaus.org)
+ * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
+ */
+public abstract class TexenTaskMojo
+    extends AbstractMojo
+{
+    /**
+     * The directory where the generator output is written to.
+     *
+     * @required
+     */
+    private String outputDir;
+
+    /**
+     * The base path where the templates are read from, if they are not read
+     * from the classpath.
+     *
+     * @parameter expression="${basedir}/src/main/torque/templates"
+     */
+    private String templatePath;
+
+    /**
+     * Whether the templates should be loaded from the classpath.
+     *
+     * @parameter expression="true"
+     */
+    private boolean useClasspath;
+
+    /**
+     * A map where all user-defined context properties can be set.
+     * Overrides all other mojo configuration settings which are mapped
+     * to context properties.
+     *
+     * @parameter
+     */
+    private Map userContextProperties;
+
+    /**
+     * The path to the generated context property file.
+     *
+     * @required
+     */
+    private String contextPropertiesPath;
+
+    /**
+     * The Maven project this plugin runs in.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * The generator task to be executed by this mojo.
+     */
+    private TexenTask generatorTask;
+
+    /**
+     * The ant project for the generator task.
+     */
+    private Project antProject;
+
+    /**
+     * Creates a new instance of AbstractTorqueMojo.
+     *
+     * @throws IllegalArgumentException if generatorTask is null.
+     */
+    public TexenTaskMojo(TexenTask generatorTask)
+    {
+        if (generatorTask == null)
+        {
+            throw new IllegalArgumentException("generatorTask is null");
+        }
+
+        // because the Texen Task needs the ant project to load its
+        // files, we need to attach one to the Texen task
+        antProject = new Project();
+        antProject.init();
+        generatorTask.setProject(antProject);
+
+        this.generatorTask = generatorTask;
+    }
+
+    /**
+     * Sets the maven project.
+     *
+     * @param project the maven project where this plugin runs in.
+     */
+    public void setProject(MavenProject project)
+    {
+        this.project = project;
+    }
+
+    /**
+     * Returns the maven project.
+     *
+     * @return The maven project where this plugin runs in.
+     */
+    public MavenProject getProject()
+    {
+        return project;
+    }
+
+    /**
+     * Returns the ant project.
+     *
+     * @return The ant project assigned to the generator task.
+     */
+    protected Project getAntProject()
+    {
+        return antProject;
+    }
+
+    /**
+     * Sets the path to Torque's output directory.
+     *
+     * @param outputDir the path to Torque's output directory.
+     */
+    public void setOutputDir(String outputDir)
+    {
+        this.outputDir = outputDir;
+    }
+
+    /**
+     * Returns the path to Torque's output directory.
+     *
+     * @return the path to Torque's output directory. Not null if
+     *         initialized correctly.
+     */
+    public String getOutputDir()
+    {
+        return this.outputDir;
+    }
+
+    /**
+     * Sets the path to Torque's templates, if the classpath is not used
+     * to load the templates.
+     *
+     * @param templatePath the path to Torque's templates.
+     */
+    public void setTemplatePath(String templatePath)
+    {
+        this.templatePath = templatePath;
+    }
+
+    /**
+     * Returns the path to Torque's templates, if the classpath is not used
+     * to load the templates.
+     *
+     * @return the path to Torque's templates.
+     */
+    public String getTemplatePath()
+    {
+        return this.templatePath;
+    }
+
+    /**
+     * Sets whether the classpath should be used to locate the templates.
+     *
+     * @param templatePath the path to Torque's templates.
+     */
+    public void setUseClasspath(boolean useClasspath)
+    {
+        this.useClasspath = useClasspath;
+    }
+
+    /**
+     * Returns whether the classpath is used to locate the templates.
+     *
+     * @return true if the classpath is used to locate the templates,
+     *         false otherwise
+     */
+    public boolean getUseClasspath()
+    {
+        return this.useClasspath;
+    }
+
+    /**
+     * Sets the path to the generated property file used as Texen's context
+     * properties.
+     *
+     * @param generatedPropertyFilePath the path to the generated context
+     *        properties file.
+     */
+    public void setContextPropertiesPath(String contextPropertiesPath)
+    {
+        this.contextPropertiesPath = contextPropertiesPath;
+    }
+
+    /**
+     * Returns the path to the generated property file used as Texen's context
+     * properties.
+     *
+     * @return the path to the generated context properties file.
+     */
+    public String getContextPropertiesPath()
+    {
+        return this.contextPropertiesPath;
+    }
+
+    /**
+     * Sets the map which defines user-defined context properties.
+     * The settings override all other mojo configuration settings
+     * which are mapped to context properties.
+     *
+     * @param contextProperties the user-defined context properties.
+     */
+    public void setUserContextProperties(Map userContextProperties)
+    {
+        this.userContextProperties = userContextProperties;
+    }
+
+    /**
+     * Returns the map which defines user-defined context properties.
+     *
+     * @return the map containing user-defined context properties,
+     *         or null if not set.
+     */
+    public Map getUserContextProperties()
+    {
+        return userContextProperties;
+    }
+
+    /**
+     * returns the generator Task for this mojo.
+     *
+     * @return the generator Task, not null.
+     */
+    protected TexenTask getGeneratorTask()
+    {
+        return generatorTask;
+    }
+
+    /**
+     * Generates the context properties file for Texen.
+     * The file is written to the path contextPropertiesPath.
+     *
+     * @throws MojoExecutionException if an error occurs.
+     */
+    protected void generateContextProperties()
+            throws MojoExecutionException
+    {
+        try
+        {
+            FileConfiguration configuration = getMojoContextProperties();
+            if (userContextProperties != null)
+            {
+                for (Iterator contextPropertyIt
+                        = userContextProperties.entrySet().iterator();
+                        contextPropertyIt.hasNext();)
+                {
+                    Map.Entry entry = (Map.Entry) contextPropertyIt.next();
+                    configuration.addProperty(
+                            entry.getKey().toString(),
+                            entry.getValue().toString());
+                }
+            }
+            configuration.save(contextPropertiesPath);
+        }
+        catch (ConfigurationException e)
+        {
+            getLog().error("Error writing temporary context properties: "
+                    + e.getMessage());
+            throw new MojoExecutionException(e.getMessage());
+        }
+    }
+
+    /**
+     * Configures the Texen task which is wrapped by this mojo.
+     * In this implementation, the context properties, useClasspath
+     * and the output directory are set. If more parameters need to be set,
+     * this method shouldb be overwritten in subclasses.
+     *
+     * @throws MojoExecutionException if an error occurs when setting the Tasks
+     *         properties.
+     */
+    protected void configureTask()
+            throws MojoExecutionException
+    {
+        generatorTask.setContextProperties(contextPropertiesPath);
+
+        generatorTask.setUseClasspath(useClasspath);
+
+        if (templatePath != null)
+        {
+            try
+            {
+                generatorTask.setTemplatePath(templatePath);
+            }
+            catch (Exception e)
+            {
+                getLog().error("Error setting template path: "
+                        + e.getMessage());
+                throw new MojoExecutionException(e.getMessage());
+            }
+        }
+
+        {
+            File outputDirectory = new File(outputDir);
+            getLog().debug("generating torque java sources into: "
+                + outputDirectory.getAbsolutePath());
+            outputDirectory.mkdirs();
+            generatorTask.setOutputDirectory(outputDirectory);
+        }
+    }
+
+    /**
+     * Executes the wrapped Texen task. Before this is done, the context
+     * properties file is generated and the Texen task is configured.
+     *
+     * @throws MojoExecutionException if an error occurs during execution.
+     *
+     * @see org.apache.maven.plugin.Mojo#execute()
+     */
+    public void execute() throws MojoExecutionException
+    {
+        generateContextProperties();
+        configureTask();
+        generatorTask.execute();
+    }
+
+    /**
+     * Returns the context properties for the Texen task which are defined
+     * in the configuration of the child mojo.
+     * This method needs to be overwritten in subclasses.
+     *
+     * @return The PropertiesConfiguration containing all context properties,
+     *         not null.
+     */
+    protected abstract PropertiesConfiguration getMojoContextProperties();
+}

Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/package.html
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/package.html?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/package.html (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/package.html Sat Nov 11 14:32:42 2006
@@ -1,23 +1,26 @@
 <!--
- Copyright 2001-2006 The Apache Software Foundation.
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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
 
- 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
 
-     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.
+ 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.
 -->
 <html>
   <head>
   </head>
   <body>
-    This package contains the mojo classes which provide maven2 access
+    This package contains the mojo classes which provide maven2 access
     to the Torque generator.
   </body>
 </html>

Modified: db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java (original)
+++ db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java Sat Nov 11 14:32:42 2006
@@ -1,188 +1,191 @@
-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.apache.torque.mojo.OMMojo;
-import org.codehaus.plexus.PlexusTestCase;
-
-
-/**
- * Tests the TorqueOMMojo
- *
- * @author Rapha�l Pi�roni (rafale_at_codehaus.org)
- */
-public class TorqueOMMojoTest
-        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);
-
-        OMMojo instance = new OMMojo();
-
-        instance.setProject(mavenProject);
-
-        instance.setOutputDir(
-                mavenProject.getBuild().getDirectory()
-                    + "/generated-sources/torque");
-        
-        instance.setContextPropertiesPath(
-                mavenProject.getBuild().getDirectory() 
-                    + "/torque/context.om.properties");
-        
-        instance.setSchemaDir(
-                mavenProject.getBasedir() + "/src/main/torque/schema");
-
-        instance.setUseClasspath(true);
-        
-        instance.setBasePrefix("Base");
-        
-        instance.setSubpackageMap("map");
-        
-        instance.setTargetPackage("org.apache.torque.mojo.test");
-        
-        instance.setSchemaIncludes("*schema.xml");
-
-        instance.setSchemaExcludes("id-table-schema.xml");
-
-        instance.setReportFile("../../torque/torque." 
-                + mavenProject.getArtifact().getArtifactId()
-                + "."
-                + "om.generation");
-        
-        instance.execute();
-
-        String generatedSourcesPackageDir 
-                = "generated-sources/torque/org/apache/torque/mojo/test/";
-        
-        assertTrue(
-                "BaseTestTable1.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "BaseTestTable1.java")
-                    .exists());
-
-        assertTrue(
-                "BaseTestTable2.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "BaseTestTable2.java")
-                    .exists());
-
-        assertTrue(
-                "BaseTestTable1Peer.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "BaseTestTable1Peer.java")
-                    .exists());
-
-        assertTrue(
-                "BaseTestTable2Peer.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "BaseTestTable2Peer.java")
-                    .exists());
-
-        assertTrue(
-                "TestTable1.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "TestTable1.java")
-                    .exists());
-
-        assertTrue(
-                "TestTable2.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "TestTable2.java")
-                    .exists());
-
-        assertTrue(
-                "TestTable1Peer.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "TestTable1Peer.java")
-                    .exists());
-
-        assertTrue(
-                "TestTable2Peer.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir + "TestTable2Peer.java")
-                    .exists());
-
-        assertTrue(
-                "TestTable1MapBuilder.java must exist",
-                new File(
-                        mavenProject.getBuild().getDirectory(),
-                        generatedSourcesPackageDir 
-                            + "map/TestTable1MapBuilder.java")
-                    .exists());
-
-        assertTrue(
-                "TestTable2MapBuilder.java must exist",
-                new File(
-                        mavenProject.getBuild ().getDirectory(),
-                        generatedSourcesPackageDir 
-                            + "map/TestTable2MapBuilder.java")
-                    .exists());
-
-        assertTrue(
-                "Project does not contain "
-                    + mavenProject.getBuild().getDirectory() 
-                    + "/generated-sources/torque"
-                    + " as compile source",
-                mavenProject.getCompileSourceRoots().contains(
-                        mavenProject.getBuild ().getDirectory()
-                            + "/generated-sources/torque"));
-    }
-}
\ No newline at end of file
+package org.apache.torque.mojo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.torque.mojo.OMMojo;
+import org.codehaus.plexus.PlexusTestCase;
+
+
+/**
+ * Tests the TorqueOMMojo
+ *
+ * @author Rapha�l Pi�roni (rafale_at_codehaus.org)
+ */
+public class TorqueOMMojoTest
+        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);
+
+        OMMojo instance = new OMMojo();
+
+        instance.setProject(mavenProject);
+
+        instance.setOutputDir(
+                mavenProject.getBuild().getDirectory()
+                    + "/generated-sources/torque");
+
+        instance.setContextPropertiesPath(
+                mavenProject.getBuild().getDirectory()
+                    + "/torque/context.om.properties");
+
+        instance.setSchemaDir(
+                mavenProject.getBasedir() + "/src/main/torque/schema");
+
+        instance.setUseClasspath(true);
+
+        instance.setBasePrefix("Base");
+
+        instance.setSubpackageMap("map");
+
+        instance.setTargetPackage("org.apache.torque.mojo.test");
+
+        instance.setSchemaIncludes("*schema.xml");
+
+        instance.setSchemaExcludes("id-table-schema.xml");
+
+        instance.setReportFile("../../torque/torque."
+                + mavenProject.getArtifact().getArtifactId()
+                + "."
+                + "om.generation");
+
+        instance.execute();
+
+        String generatedSourcesPackageDir
+                = "generated-sources/torque/org/apache/torque/mojo/test/";
+
+        assertTrue(
+                "BaseTestTable1.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "BaseTestTable1.java")
+                    .exists());
+
+        assertTrue(
+                "BaseTestTable2.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "BaseTestTable2.java")
+                    .exists());
+
+        assertTrue(
+                "BaseTestTable1Peer.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "BaseTestTable1Peer.java")
+                    .exists());
+
+        assertTrue(
+                "BaseTestTable2Peer.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "BaseTestTable2Peer.java")
+                    .exists());
+
+        assertTrue(
+                "TestTable1.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "TestTable1.java")
+                    .exists());
+
+        assertTrue(
+                "TestTable2.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "TestTable2.java")
+                    .exists());
+
+        assertTrue(
+                "TestTable1Peer.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "TestTable1Peer.java")
+                    .exists());
+
+        assertTrue(
+                "TestTable2Peer.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir + "TestTable2Peer.java")
+                    .exists());
+
+        assertTrue(
+                "TestTable1MapBuilder.java must exist",
+                new File(
+                        mavenProject.getBuild().getDirectory(),
+                        generatedSourcesPackageDir
+                            + "map/TestTable1MapBuilder.java")
+                    .exists());
+
+        assertTrue(
+                "TestTable2MapBuilder.java must exist",
+                new File(
+                        mavenProject.getBuild ().getDirectory(),
+                        generatedSourcesPackageDir
+                            + "map/TestTable2MapBuilder.java")
+                    .exists());
+
+        assertTrue(
+                "Project does not contain "
+                    + mavenProject.getBuild().getDirectory()
+                    + "/generated-sources/torque"
+                    + " as compile source",
+                mavenProject.getCompileSourceRoots().contains(
+                        mavenProject.getBuild ().getDirectory()
+                            + "/generated-sources/torque"));
+    }
+}

Modified: db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java (original)
+++ db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueSQLMojoTest.java Sat Nov 11 14:32:42 2006
@@ -1,124 +1,127 @@
-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
+package org.apache.torque.mojo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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());
+    }
+}

Modified: db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/pom.xml?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/pom.xml (original)
+++ db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/pom.xml Sat Nov 11 14:32:42 2006
@@ -1,25 +1,43 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--                                                                            -->
-<!-- Copyright 2001-2005 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.                                             -->
-<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/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>torque</groupId>
-  <artifactId>test-TorqueOMMojoTest</artifactId>
-  <version>1.0</version>
-  <name>Test project 1</name>
-</project>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--                                                                            -->
+<!-- Copyright 2001-2005 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.                                             -->
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>torque</groupId>
+  <artifactId>test-TorqueOMMojoTest</artifactId>
+  <version>1.0</version>
+  <name>Test project 1</name>
+</project>

Modified: db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/id-table-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/id-table-schema.xml?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/id-table-schema.xml (original)
+++ db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/id-table-schema.xml Sat Nov 11 14:32:42 2006
@@ -1,43 +1,46 @@
-<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
-<!--
- Copyright 2001-2005 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.
--->
-<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_2.dtd">
-
-<!-- ==================================================================== -->
-<!--                                                                      -->
-<!-- I D  B R O K E R  S C H E M A                                        -->
-<!--                                                                      -->
-<!-- ==================================================================== -->
-<!-- This is the XML schema use by Torque to generate the SQL for         -->
-<!-- ID_TABLE table used by the id broker mechanism in Torque.            -->
-<!-- ==================================================================== -->
-<!-- @author: <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>      -->
-<!-- @version $Id: id-table-schema.xml 279108 2005-09-06 21:04:30Z tfischer $ -->
-<!-- ==================================================================== -->
-
-<database name="@DATABASE_DEFAULT@">
-  <table name="ID_TABLE" idMethod="idbroker">
-    <column name="ID_TABLE_ID" required="true" primaryKey="true" type="INTEGER"/>
-    <column name="TABLE_NAME" required="true" size="250" type="VARCHAR"/>
-    <column name="NEXT_ID" type="INTEGER"/>
-    <column name="QUANTITY" type="INTEGER"/>
-
-    <unique>
-      <unique-column name="TABLE_NAME"/>
-    </unique>
-
-  </table>
-</database>
+<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_2.dtd">
+
+<!-- ==================================================================== -->
+<!--                                                                      -->
+<!-- I D  B R O K E R  S C H E M A                                        -->
+<!--                                                                      -->
+<!-- ==================================================================== -->
+<!-- This is the XML schema use by Torque to generate the SQL for         -->
+<!-- ID_TABLE table used by the id broker mechanism in Torque.            -->
+<!-- ==================================================================== -->
+<!-- @author: <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>      -->
+<!-- @version $Id: id-table-schema.xml 279108 2005-09-06 21:04:30Z tfischer $ -->
+<!-- ==================================================================== -->
+
+<database name="@DATABASE_DEFAULT@">
+  <table name="ID_TABLE" idMethod="idbroker">
+    <column name="ID_TABLE_ID" required="true" primaryKey="true" type="INTEGER"/>
+    <column name="TABLE_NAME" required="true" size="250" type="VARCHAR"/>
+    <column name="NEXT_ID" type="INTEGER"/>
+    <column name="QUANTITY" type="INTEGER"/>
+
+    <unique>
+      <unique-column name="TABLE_NAME"/>
+    </unique>
+
+  </table>
+</database>

Modified: db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/test-TorqueOMMojoTest-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/test-TorqueOMMojoTest-schema.xml?view=diff&rev=473817&r1=473816&r2=473817
==============================================================================
--- db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/test-TorqueOMMojoTest-schema.xml (original)
+++ db/torque/maven2-plugin/trunk/src/test/resources/projects/TorqueOMMojoTest/src/main/torque/schema/test-TorqueOMMojoTest-schema.xml Sat Nov 11 14:32:42 2006
@@ -1,41 +1,44 @@
-<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
-<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_2.dtd">
-
-<!--
- * 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.
--->
-
-<database name="testdatabase">
-
-  <table name="TEST_TABLE_1" idMethod="idbroker">
-    <column name="ATTRIBUTE_1" required="true" primaryKey="true" type="INTEGER"/>
-    <column name="ATTRIBUTE_2" required="true" size="32" type="VARCHAR"/>
-    <column name="ATTRIBUTE_3" type="BOOLEANINT"/>
-
-    <unique>
-      <unique-column name="ATTRIBUTE_2"/>
-    </unique>        
-  </table>
-
-  <table name="TEST_TABLE_2">
-    <column name="ATTRIBUTE_1" required="true" primaryKey="true" type="INTEGER"/>
-    <column name="ATTRIBUTE_2" required="true" primaryKey="true" type="INTEGER"/>
-
-    <foreign-key foreignTable="TEST_TABLE_1">
-      <reference local="ATTRIBUTE_1" foreign="ATTRIBUTE_1"/>
-    </foreign-key>
-  </table>
-	
-</database>
+<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
+<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_2.dtd">
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+
+<database name="testdatabase">
+
+  <table name="TEST_TABLE_1" idMethod="idbroker">
+    <column name="ATTRIBUTE_1" required="true" primaryKey="true" type="INTEGER"/>
+    <column name="ATTRIBUTE_2" required="true" size="32" type="VARCHAR"/>
+    <column name="ATTRIBUTE_3" type="BOOLEANINT"/>
+
+    <unique>
+      <unique-column name="ATTRIBUTE_2"/>
+    </unique>
+  </table>
+
+  <table name="TEST_TABLE_2">
+    <column name="ATTRIBUTE_1" required="true" primaryKey="true" type="INTEGER"/>
+    <column name="ATTRIBUTE_2" required="true" primaryKey="true" type="INTEGER"/>
+
+    <foreign-key foreignTable="TEST_TABLE_1">
+      <reference local="ATTRIBUTE_1" foreign="ATTRIBUTE_1"/>
+    </foreign-key>
+  </table>
+
+</database>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message