[prev in list] [next in list] [prev in thread] [next in thread] 

List:       turbine-torque-dev
Subject:    svn commit: r1403470 - in /db/torque/torque4/trunk/torque-templates/src/test: java/org/apache/torque
From:       tfischer () apache ! org
Date:       2012-10-29 19:49:57
Message-ID: 20121029194957.3870523888E3 () eris ! apache ! org
[Download RAW message or body]

Author: tfischer
Date: Mon Oct 29 19:49:56 2012
New Revision: 1403470

URL: http://svn.apache.org/viewvc?rev=1403470&view=rev
Log:
Add test case to cover the "access generator from java" section in the docs

Added:
    db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/GenerateOmClassesFromJavaTest.java \
(with props)  db/torque/torque4/trunk/torque-templates/src/test/simple-schema/
    db/torque/torque4/trunk/torque-templates/src/test/simple-schema/schema.xml   \
(with props)

Added: db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/GenerateOmClassesFromJavaTest.java
                
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/ja \
va/org/apache/torque/templates/GenerateOmClassesFromJavaTest.java?rev=1403470&view=auto
 ==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/GenerateOmClassesFromJavaTest.java \
                (added)
+++ db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/GenerateOmClassesFromJavaTest.java \
Mon Oct 29 19:49:56 2012 @@ -0,0 +1,69 @@
+package org.apache.torque.templates;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.torque.generator.configuration.UnitDescriptor;
+import org.apache.torque.generator.configuration.option.MapOptionsConfiguration;
+import org.apache.torque.generator.configuration.paths.CustomProjectPaths;
+import org.apache.torque.generator.configuration.paths.DefaultTorqueGeneratorPaths;
+import org.apache.torque.generator.configuration.paths.Maven2DirectoryProjectPaths;
+import org.apache.torque.generator.configuration.paths.Maven2ProjectPaths;
+import org.apache.torque.generator.control.Controller;
+import org.junit.Test;
+
+/**
+ * Tests how to access the templates from java.
+ *
+ * This does not really test the templates,
+ * however in the reference documentation it is mentioned how to use
+ * the genrator/tempaltes from java, and this test makes sure it works
+ * as documented.
+ *
+ * @version $Id$
+ */
+public class GenerateOmClassesFromJavaTest
+{
+     @Test
+     public void generateOMClassesFromJava() throws Exception
+     {
+         Controller controller = new Controller();
+         List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+
+         Map<String, String> overrideOptions = new HashMap<String, String>();
+         overrideOptions.put("torque.om.package", \
"org.apache.torque.templates.test"); +
+         CustomProjectPaths projectPaths
+                 = new CustomProjectPaths(
+                     new Maven2DirectoryProjectPaths(new File(".")));
+         projectPaths.setConfigurationPackage("org.apache.torque.templates.om");
+         projectPaths.setConfigurationDir(null);
+         projectPaths.setSourceDir(new File("src/test/simple-schema"));
+         projectPaths.setOutputDirectory(
+                 null,
+                 new File("target/generateOmClassesFromJava/default"));
+         projectPaths.setOutputDirectory(
+                 Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY,
+                 new File("target/generateOmClassesFromJava/modifiable"));
+         UnitDescriptor unitDescriptor = new UnitDescriptor(
+                 UnitDescriptor.Packaging.CLASSPATH,
+                 projectPaths,
+                 new DefaultTorqueGeneratorPaths());
+         unitDescriptor.setOverrideOptions(
+                 new MapOptionsConfiguration(overrideOptions));
+         unitDescriptors.add(unitDescriptor);
+
+         controller.run(unitDescriptors);
+         assertTrue(
+                 new \
File("target/generateOmClassesFromJava/default/org/apache/torque/templates/test/BaseAPeer.java")
 +                     .exists());
+         assertTrue(
+                 new \
File("target/generateOmClassesFromJava/modifiable/org/apache/torque/templates/test/APeer.java")
 +                     .exists());
+     }
+}

Propchange: db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/GenerateOmClassesFromJavaTest.java
                
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: db/torque/torque4/trunk/torque-templates/src/test/simple-schema/schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/simple-schema/schema.xml?rev=1403470&view=auto
 ==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/simple-schema/schema.xml \
                (added)
+++ db/torque/torque4/trunk/torque-templates/src/test/simple-schema/schema.xml Mon \
Oct 29 19:49:56 2012 @@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ 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
+    xmlns="http://db.apache.org/torque/4.0/templates/database"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/4.0/templates/database
+        http://db.apache.org/torque/4.0/templates/database-strict.xsd"
+    name="bookstore"
+    defaultIdMethod="native">
+
+  <table name="a" description="A table">
+    <column
+      name="a_id"
+      required="true"
+      primaryKey="true"
+      type="INTEGER"
+    />
+    <column
+      name="name"
+      required="true"
+      type="VARCHAR"
+      size="50"
+    />
+
+  </table>
+</database>

Propchange: db/torque/torque4/trunk/torque-templates/src/test/simple-schema/schema.xml
                
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic