db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r910600 [15/29] - in /db/torque/torque4/trunk: maven-torque-gf-plugin/ maven-torque-gf-plugin/src/ maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/ maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/m...
Date Tue, 16 Feb 2010 17:16:02 GMT
Added: db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/generatorDefs/generators.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/generatorDefs/generators.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/generatorDefs/generators.xml (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/generatorDefs/generators.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<generators xmlns="http://db.apache.org/torque/gf/4.0/configuration"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/generator.xsd"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <generator name="nestingGenerator0"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator1"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator1"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator2"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator2"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator3"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator3"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator4"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator4"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator5"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator5"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator6"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator6"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator7"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator7"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator8"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator8"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="nestingGenerator9"/>
+    </mergepoint>
+  </generator>
+  <generator name="nestingGenerator9"
+      xsi:type="velocityGenerator" 
+      path="nesting.vm">
+    <mergepoint name="mergepoint">
+      <action xsi:type="applyAction" generator="contentGenerator"/>
+    </mergepoint>
+  </generator>
+  <generator name="contentGenerator"
+      xsi:type="velocityGenerator" 
+      path="content.vm"/>
+</generators>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/src/source.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/src/source.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/src/source.xml (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/src/source.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<sourceElement />
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/content.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/content.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/content.vm (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/content.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,18 @@
+## 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.
+##
+content
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/nesting.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/nesting.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/nesting.vm (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/templates/nesting.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,18 @@
+## 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.
+##
+$torqueGf.mergepoint("mergepoint")
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/1.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/1.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/1.properties (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/1.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,18 @@
+# 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.
+
+1=1
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/11.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/11.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/11.properties (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/11.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,18 @@
+# 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.
+
+11=11
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/2.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/2.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/2.properties (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/2.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,18 @@
+# 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.
+
+2=2
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/subsubfolder/3.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/subsubfolder/3.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/subsubfolder/3.properties (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/fileSourcesImpl/subfolder/subsubfolder/3.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,18 @@
+# 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.
+
+3=3
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/BaseTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/BaseTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/BaseTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/BaseTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,34 @@
+package org.apache.torque.gf;
+
+/*
+ * 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.log4j.BasicConfigurator;
+
+/**
+ * Base class for all tests. Configures the logger.
+ */
+public abstract class BaseTest
+{
+
+    static
+    {
+        BasicConfigurator.configure();
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,881 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+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.commons.lang.StringUtils;
+import org.apache.torque.gf.BaseTest;
+import org.apache.torque.gf.configuration.controller.GeneratorReference;
+import org.apache.torque.gf.configuration.controller.Loglevel;
+import org.apache.torque.gf.configuration.controller.Output;
+import org.apache.torque.gf.configuration.generator.GeneratorConfiguration;
+import org.apache.torque.gf.configuration.mergepoint.MergepointMapping;
+import org.apache.torque.gf.configuration.option.MapOptionsConfiguration;
+import org.apache.torque.gf.configuration.option.OptionsConfiguration;
+import org.apache.torque.gf.configuration.paths.CustomProjectPaths;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.ControllerState;
+import org.apache.torque.gf.control.action.ApplyAction;
+import org.apache.torque.gf.control.action.MergepointAction;
+import org.apache.torque.gf.control.action.TraverseAllAction;
+import org.apache.torque.gf.generator.Generator;
+import org.apache.torque.gf.java.JavaGenerator;
+import org.apache.torque.gf.option.Option;
+import org.apache.torque.gf.option.OptionImpl;
+import org.apache.torque.gf.option.Options;
+import org.apache.torque.gf.qname.QualifiedName;
+import org.apache.torque.gf.source.FileSourcesImpl;
+import org.apache.torque.gf.source.TransformerDefinition;
+import org.apache.torque.gf.source.properties.PropertiesSourceType;
+import org.apache.torque.gf.source.xml.XmlSourceType;
+import org.apache.torque.gf.template.velocity.VelocityGenerator;
+import org.junit.Test;
+
+
+/**
+ * Tests whether the configuration is read correctly.
+ */
+public class ReadConfigurationTest extends BaseTest
+{
+    private ControllerState controllerState = new ControllerState();
+
+    @Test
+    public void testReadConfiguration() throws Exception
+    {
+        ProjectPaths projectPaths = new Maven2DirectoryProjectPaths(
+                new File("src/test/configuration"));
+        UnitDescriptor unitDescriptor = new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                projectPaths,
+                new DefaultTorqueGfPaths());
+        UnitConfigurationReader configurationReader
+                = new UnitConfigurationReader();
+        ConfigurationHandlers configurationHandlers
+                = new ConfigurationHandlers();
+        UnitConfiguration unitConfiguration
+                = configurationReader.read(
+                        unitDescriptor,
+                        configurationHandlers);
+
+        {
+            File newFileTargetDirectory
+                    = unitConfiguration.getNewFileTargetDirectory();
+            File expected = new File(
+                    "src/test/configuration/target/generated-sources");
+            assertEquals(expected, newFileTargetDirectory);
+        }
+        {
+            File modifiedFileTargetDirectory
+                    = unitConfiguration.getModifiedFileTargetDirectory();
+            File expected = new File(
+                    "src/test/configuration/src/main/generated-sources");
+            assertEquals(expected, modifiedFileTargetDirectory);
+        }
+
+        assertEquals(Loglevel.DEBUG, unitConfiguration.getLoglevel());
+
+        {
+            Options options = unitConfiguration.getOptions();
+
+            Map<QualifiedName, Option> globalScope = options.getGlobalScope();
+            assertEquals(4, globalScope.size());
+
+            // check normal options
+            {
+                QualifiedName optionWithNamespaceQName
+                        = new QualifiedName(
+                                "org.apache.torque.gf.optionWithNamespace");
+                Option optionWithNamespace
+                        = globalScope.get(optionWithNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithNamespaceQName,
+                                "optionWithNamespaceValue"),
+                        optionWithNamespace);
+            }
+            {
+                QualifiedName optionWithNamespaceQName
+                        = new QualifiedName(
+                                "org.apache.optionWithNamespace");
+                Option optionWithNamespace
+                        = globalScope.get(optionWithNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithNamespaceQName,
+                                "org.apache.optionWithNamespaceValue"),
+                        optionWithNamespace);
+            }
+            {
+                QualifiedName optionWithNamespaceQName
+                        = new QualifiedName(
+                                "optionWithoutNamespace", "");
+                Option optionWithNamespace
+                        = globalScope.get(optionWithNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithNamespaceQName,
+                                "optionWithoutNamespaceValue"),
+                        optionWithNamespace);
+            }
+            // check option from last file takes precedence
+            {
+                QualifiedName optionWithNamespaceQName
+                        = new QualifiedName(
+                                "optionPrecedenceLastFile");
+                Option optionWithNamespace
+                        = globalScope.get(optionWithNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithNamespaceQName,
+                                "value from xml"),
+                        optionWithNamespace);
+            }
+        }
+
+        {
+            List<Output> outputFiles = unitConfiguration.getOutputFiles();
+            assertEquals(3, outputFiles.size());
+
+            {
+                Output outputFile = outputFiles.get(0);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("org.apache.torque.gf.firstOutput"));
+
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.javaGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+                assertNull(outputFile.getFilename());
+                assertTrue(outputFile.isSkipIfExists());
+
+                {
+                    JavaGenerator filenameGenerator
+                            = (JavaGenerator) outputFile.getFilenameGenerator();
+                    assertEquals("Foo", filenameGenerator.getFoo());
+                    assertEquals("Bar", filenameGenerator.getBar());
+                    assertEquals(
+                            new QualifiedName(
+                                    "org.apache.torque.gf.configuration.filenameGenerator"),
+                            filenameGenerator.getName());
+                }
+
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            new XmlSourceType(),
+                            "source",
+                            null,
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                    // TODO: add source Transformers to config file & check here they are added
+                }
+            }
+
+            {
+                Output outputFile = outputFiles.get(1);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("secondOutput"));
+
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.anotherGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+
+                assertNull(outputFile.getFilename());
+                assertFalse(outputFile.isSkipIfExists());
+
+                {
+                    VelocityGenerator filenameGenerator
+                            = (VelocityGenerator) outputFile.getFilenameGenerator();
+                    String templateContent
+                            = filenameGenerator.getContent(controllerState);
+                    // remove License from template by comparing only
+                    // the last line
+                    String templateContentLicenseRemoved
+                            = StringUtils.substringAfterLast(templateContent, "\r\n");
+                    assertEquals(
+                            "test template output",
+                            templateContentLicenseRemoved);
+                    assertEquals(
+                            new QualifiedName(
+                                    "org.apache.torque.gf.configuration.filenameGenerator"),
+                            filenameGenerator.getName());
+                    assertTrue(filenameGenerator.isOptionsInContext());
+                    assertTrue(filenameGenerator.isSourceAttributesInContext());
+                    assertTrue(filenameGenerator.isVariablesInContext());
+                }
+
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            new PropertiesSourceType(),
+                            "secondSourcePath",
+                            "properties/entry",
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                }
+            }
+            {
+                Output outputFile = outputFiles.get(2);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("thirdOutput"));
+
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.thirdGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+
+                assertEquals("outputFileName", outputFile.getFilename());
+                assertNull(outputFile.getFilenameGenerator());
+                assertFalse(outputFile.isSkipIfExists());
+
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            null,
+                            "third.source.path.properties",
+                            null,
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                }
+            }
+        }
+
+        {
+            GeneratorConfiguration generatorConfiguration
+                    = unitConfiguration.getGeneratorConfiguration();
+            Map <QualifiedName, Generator> generatorMap
+                    = generatorConfiguration.getGenerators();
+            assertEquals(2, generatorMap.size());
+            {
+                JavaGenerator generator
+                        = (JavaGenerator) generatorMap.get(new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.javaGenerator"));
+                assertEquals("Foo2", generator.getFoo());
+                assertEquals("Bar2", generator.getBar());
+                Map<String, MergepointMapping> mergepointMappings
+                        = generator.getMergepointMappings();
+                assertEquals(3, mergepointMappings.size());
+                {
+                    MergepointMapping mergepointMapping
+                            = mergepointMappings.get("properties");
+                    assertEquals(1, mergepointMapping.getActions().size());
+                    MergepointAction action
+                            = mergepointMapping.getActions().get(0);
+                    assertEquals(
+                            new TraverseAllAction(
+                                    "entry",
+                                    "org.apache.torque.gf.velocity.propertyCopy",
+                                    true),
+                            action);
+                    assertEquals("inputElement", generator.getInputElementName());
+                }
+                {
+                    // mergepoint from the separate mapping
+                    MergepointMapping mergepointMapping
+                            = mergepointMappings.get("mergepointName");
+                    assertEquals(1, mergepointMapping.getActions().size());
+                    MergepointAction action 
+                            = mergepointMapping.getActions().get(0);
+                    assertEquals(
+                            new ApplyAction(
+                                    null,
+                                    "someGeneratorAction",
+                                    false),
+                            action);
+                    assertEquals("inputElement", generator.getInputElementName());
+                }
+                {
+                    // other mergepoint from the separate mapping
+                    MergepointMapping mergepointMapping
+                            = mergepointMappings.get("mergepointFromParent");
+                    assertEquals(1, mergepointMapping.getActions().size());
+                    MergepointAction action
+                            = mergepointMapping.getActions().get(0);
+                    assertEquals(
+                            new ApplyAction(
+                                    null,
+                                    "newGeneratorAction",
+                                    true),
+                            action);
+                    assertEquals("inputElement", generator.getInputElementName());
+                }
+            }
+
+            {
+                VelocityGenerator generator
+                        = (VelocityGenerator) generatorMap.get(new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.anotherGenerator"));
+                String templateContent
+                        = generator.getContent(controllerState);
+                // remove License from template by comparing only
+                // the last line
+                String templateContentLicenseRemoved
+                        = StringUtils.substringAfterLast(templateContent, "\r\n");
+                assertEquals(
+                        "test template output",
+                        templateContentLicenseRemoved);
+                assertEquals(0, generator.getMergepointMappings().size());
+                assertNull(generator.getInputElementName());
+                assertFalse(generator.isOptionsInContext());
+                assertFalse(generator.isSourceAttributesInContext());
+                assertFalse(generator.isVariablesInContext());
+            }
+        }
+    }
+
+    @Test
+    public void testReadConfigFromClasspath() throws Exception
+    {
+        ProjectPaths projectPaths = new CustomProjectPaths(
+                null,
+                "org.apache.torque.gf.test.readfromclasspath",
+                new File("src"),
+                new File("target"),
+                new File("generated-src"));
+        UnitDescriptor unitDescriptor = new UnitDescriptor(
+                UnitDescriptor.Packaging.CLASSPATH,
+                projectPaths,
+                new DefaultTorqueGfPaths());
+        ConfigurationHandlers configurationHandlers
+                = new ConfigurationHandlers();
+        UnitConfigurationReader configurationReader
+                = new UnitConfigurationReader();
+        UnitConfiguration unitConfiguration
+                = configurationReader.read(
+                        unitDescriptor,
+                        configurationHandlers);
+
+        // check that we have read the correct configuration
+        {
+            Options options = unitConfiguration.getOptions();
+            Option option  = options.getInHierarchy(
+                    new QualifiedName("configuration"));
+            assertNotNull("option configuration should be set", option);
+            assertEquals("fromClasspath", option.getValue());
+        }
+
+        // check that the generators are read
+        {
+            GeneratorConfiguration generatorConfiguration
+                    = unitConfiguration.getGeneratorConfiguration();
+            Map <QualifiedName, Generator> generatorMap
+                    = generatorConfiguration.getGenerators();
+            assertEquals(2, generatorMap.size());
+        }
+    }
+
+    @Test
+    public void testOverrideOptions() throws Exception
+    {
+        ProjectPaths projectPaths = new Maven2DirectoryProjectPaths(
+                new File("src/test/configuration"));
+        Map<String, String> overrideOptions = new HashMap<String, String>();
+        overrideOptions.put("optionWithoutNamespace", "overriddenValue");
+        overrideOptions.put("newOption", "newValue");
+        OptionsConfiguration optionConfiguration
+                = new MapOptionsConfiguration(overrideOptions);
+
+        UnitDescriptor unitDescriptor = new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                projectPaths,
+                new DefaultTorqueGfPaths(),
+                null,
+                optionConfiguration,
+                null);
+        ConfigurationHandlers configurationHandlers
+                = new ConfigurationHandlers();
+        UnitConfigurationReader configurationReader
+                = new UnitConfigurationReader();
+        UnitConfiguration unitConfiguration
+                = configurationReader.read(
+                        unitDescriptor,
+                        configurationHandlers);
+        Options options = unitConfiguration.getOptions();
+        {
+            Option option = options.getInHierarchy(
+                    new QualifiedName("optionWithoutNamespace"));
+            assertEquals("overriddenValue", option.getValue());
+        }
+        {
+            Option option = options.getInHierarchy(
+                    new QualifiedName("newOption"));
+            assertEquals("newValue", option.getValue());
+        }
+    }
+
+
+    @Test
+    public void testInheritance() throws Exception
+    {
+        CustomProjectPaths projectPaths;
+        UnitConfiguration unitConfiguration;
+        ConfigurationHandlers configurationHandlers
+                = new ConfigurationHandlers();
+        {
+            CustomProjectPaths parentProjectPaths
+                    = new CustomProjectPaths(
+                            new Maven2DirectoryProjectPaths(
+                                    new File("src/test/configuration")));
+            parentProjectPaths.setConfigurationDir(
+                    new File("src/test/configuration/src/main/torque-gf-parent"));
+            parentProjectPaths.setNewFileTargetDir(
+                    new File("src/test/configuration/target/parentCustom"));
+            parentProjectPaths.setModifiedFileTargetDir(
+                    new File("src/test/configuration/src/main/parentCustom"));
+            UnitDescriptor parentUnitDescriptor = new UnitDescriptor(
+                    UnitDescriptor.Packaging.DIRECTORY,
+                    parentProjectPaths,
+                    new DefaultTorqueGfPaths(),
+                    null,
+                    null,
+                    null);
+
+            projectPaths = new CustomProjectPaths(
+                    new Maven2DirectoryProjectPaths(
+                            new File("src/test/configuration")));
+            projectPaths.setNewFileTargetDir(
+                    new File("src/test/configuration/target/custom"));
+            projectPaths.setModifiedFileTargetDir(
+                    new File("src/test/configuration/src/main/custom"));
+            UnitDescriptor unitDescriptor = new UnitDescriptor(
+                    UnitDescriptor.Packaging.DIRECTORY,
+                    projectPaths,
+                    new DefaultTorqueGfPaths(),
+                    parentUnitDescriptor,
+                    null,
+                    null);
+            UnitConfigurationReader configurationReader
+                    = new UnitConfigurationReader();
+            unitConfiguration
+                    = configurationReader.read(
+                            unitDescriptor,
+                            configurationHandlers);
+        }
+
+        assertEquals(Loglevel.DEBUG, unitConfiguration.getLoglevel());
+
+        {
+            File newFileTargetDirectory
+                    = unitConfiguration.getNewFileTargetDirectory();
+            File expected = new File("src/test/configuration/target/custom");
+            assertEquals(expected, newFileTargetDirectory);
+        }
+        {
+            File modifiedFileTargetDirectory
+                    = unitConfiguration.getModifiedFileTargetDirectory();
+            File expected = new File("src/test/configuration/src/main/custom");
+            assertEquals(expected, modifiedFileTargetDirectory);
+        }
+
+        {
+            Options options = unitConfiguration.getOptions();
+            Map<QualifiedName, Option> globalScope = options.getGlobalScope();
+            assertEquals(6, globalScope.size());
+
+            {
+                QualifiedName optionWithoutNamespaceQName
+                        = new QualifiedName("optionWithoutNamespace", "");
+                Option optionWithoutNamespace
+                        = globalScope.get(optionWithoutNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithoutNamespaceQName,
+                                "optionWithoutNamespaceValue"),
+                        optionWithoutNamespace);
+            }
+            {
+                QualifiedName optionWithNamespaceQName
+                        = new QualifiedName(
+                                "org.apache.torque.gf.optionWithNamespace");
+                Option optionWithNamespace
+                        = globalScope.get(optionWithNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithNamespaceQName,
+                                "optionWithNamespaceValue"),
+                        optionWithNamespace);
+            }
+            {
+                QualifiedName optionWithoutNamespaceQName
+                        = new QualifiedName("parentOptionWithoutNamespace", "");
+                Option optionWithoutNamespace
+                        = globalScope.get(optionWithoutNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithoutNamespaceQName,
+                                "parentOptionWithoutNamespaceParentValue"),
+                        optionWithoutNamespace);
+            }
+            {
+                QualifiedName optionWithNamespaceQName
+                        = new QualifiedName(
+                                "org.apache.torque.gf.parentOptionWithNamespace");
+                Option optionWithNamespace
+                        = globalScope.get(optionWithNamespaceQName);
+                assertEquals(
+                        new OptionImpl(
+                                optionWithNamespaceQName,
+                                "parentOptionWithNamespaceParentValue"),
+                        optionWithNamespace);
+            }
+        }
+        {
+            List<Output> outputFiles = unitConfiguration.getOutputFiles();
+            assertEquals(4, outputFiles.size());
+
+            {
+                Output outputFile = outputFiles.get(0);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("parentOutput"));
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.testParentGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+
+                assertNull(outputFile.getFilename());
+
+                {
+                    JavaGenerator filenameGenerator
+                            = (JavaGenerator) outputFile.getFilenameGenerator();
+                    assertEquals("ParentFoo", filenameGenerator.getFoo());
+                    assertEquals("ParentBar", filenameGenerator.getBar());
+                    assertEquals(
+                            new QualifiedName(
+                                    "org.apache.torque.gf.configuration.filenameGenerator"),
+                            filenameGenerator.getName());
+                }
+
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            new XmlSourceType(),
+                            "parentSource",
+                            null,
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                }
+            }
+            {
+                Output outputFile = outputFiles.get(1);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("org.apache.torque.gf.firstOutput"));
+
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.javaGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+
+                assertNull(outputFile.getFilename());
+
+                {
+                    JavaGenerator filenameGenerator
+                            = (JavaGenerator) outputFile.getFilenameGenerator();
+                    assertEquals("Foo", filenameGenerator.getFoo());
+                    assertEquals("Bar", filenameGenerator.getBar());
+                    assertEquals(
+                            new QualifiedName(
+                                    "org.apache.torque.gf.configuration.filenameGenerator"),
+                            filenameGenerator.getName());
+                }
+
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            new XmlSourceType(),
+                            "source",
+                            null,
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                    // TODO: add source Transformers to config file & check here they are added
+                }
+            }
+
+            {
+                Output outputFile = outputFiles.get(2);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("secondOutput"));
+
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.anotherGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+
+                assertNull(outputFile.getFilename());
+
+                {
+                    VelocityGenerator filenameGenerator
+                            = (VelocityGenerator) outputFile.getFilenameGenerator();
+                    String templateContent
+                            = filenameGenerator.getContent(controllerState);
+                    // remove License from template by comparing only
+                    // the last line
+                    String templateContentLicenseRemoved
+                            = StringUtils.substringAfterLast(templateContent, "\r\n");
+                    assertEquals(
+                            "test template output",
+                            templateContentLicenseRemoved);
+                    assertEquals(
+                            new QualifiedName(
+                                    "org.apache.torque.gf.configuration.filenameGenerator"),
+                            filenameGenerator.getName());
+                }
+
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            new PropertiesSourceType(),
+                            "secondSourcePath",
+                            "properties/entry",
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                }
+            }
+            {
+                Output outputFile = outputFiles.get(3);
+                assertEquals(
+                        outputFile.getName(),
+                        new QualifiedName("thirdOutput"));
+
+                {
+                    GeneratorReference generatorConfiguration
+                            = outputFile.getContentGenerator();
+                    assertEquals(
+                            new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.thirdGenerator"),
+                            generatorConfiguration.getName());
+                }
+
+                assertEquals("outputFileName", outputFile.getFilename());
+                assertNull(outputFile.getFilenameGenerator());
+                {
+                    FileSourcesImpl sources = new FileSourcesImpl(
+                            null,
+                            "third.source.path.properties",
+                            null,
+                            null,
+                            new ArrayList<TransformerDefinition>(),
+                            configurationHandlers,
+                            projectPaths.getDefaultSourcePath());
+                    assertSourcesEquals(
+                            sources,
+                            (FileSourcesImpl) outputFile.getSources());
+                }
+            }
+        }
+
+        {
+            GeneratorConfiguration generatorConfiguration
+                    = unitConfiguration.getGeneratorConfiguration();
+            Map <QualifiedName, Generator> generatorMap
+                    = generatorConfiguration.getGenerators();
+            assertEquals(3, generatorMap.size());
+            {
+                JavaGenerator generator
+                        = (JavaGenerator) generatorMap.get(new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.javaGenerator"));
+                assertEquals("Foo2", generator.getFoo());
+                assertEquals("Bar2", generator.getBar());
+                Map<String,MergepointMapping> mergepointMappings
+                        = generator.getMergepointMappings();
+                assertEquals(3, mergepointMappings.size());
+                {
+                    MergepointMapping mergepointMapping 
+                            = mergepointMappings.get("properties");
+                    assertEquals(1, mergepointMapping.getActions().size());
+                    MergepointAction action 
+                            = mergepointMapping.getActions().get(0);
+                    assertEquals(
+                            new TraverseAllAction(
+                                    "entry",
+                                    "org.apache.torque.gf.velocity.propertyCopy",
+                                    true),
+                            action);
+                    assertEquals("inputElement", generator.getInputElementName());                    
+                }
+                {
+                    // mergepoint from the separate mapping in child
+                    MergepointMapping mergepointMapping 
+                            = mergepointMappings.get("mergepointName");
+                    assertEquals(1, mergepointMapping.getActions().size());
+                    MergepointAction action 
+                            = mergepointMapping.getActions().get(0);
+                    assertEquals(
+                            new ApplyAction(
+                                    null,
+                                    "someGeneratorAction",
+                                    false),
+                            action);
+                    assertEquals("inputElement", generator.getInputElementName());
+                }
+                {
+                    // other mergepoint from the separate mapping in child
+                    MergepointMapping mergepointMapping 
+                            = mergepointMappings.get("mergepointFromParent");
+                    assertEquals(1, mergepointMapping.getActions().size());
+                    MergepointAction action 
+                            = mergepointMapping.getActions().get(0);
+                    assertEquals(
+                            new ApplyAction(
+                                    null,
+                                    "newGeneratorAction",
+                                    true),
+                            action);
+                    assertEquals("inputElement", generator.getInputElementName());
+                }
+            }
+
+            {
+                VelocityGenerator generator
+                        = (VelocityGenerator) generatorMap.get(new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.anotherGenerator"));
+                String templateContent
+                        = generator.getContent(controllerState);
+                // remove License from template by comparing only
+                // the last line
+                String templateContentLicenseRemoved
+                        = StringUtils.substringAfterLast(templateContent, "\r\n");
+                assertEquals(
+                        "test template output",
+                        templateContentLicenseRemoved);
+                assertEquals(0, generator.getMergepointMappings().size());
+            }
+            {
+                VelocityGenerator generator
+                        = (VelocityGenerator) generatorMap.get(new QualifiedName(
+                                "org.apache.torque.gf.test.readConfiguration.parentGenerator"));
+                String templateContent
+                        = generator.getContent(controllerState);
+                // remove License from template by comparing only
+                // the last line
+                String templateContentLicenseRemoved
+                = StringUtils.substringAfterLast(templateContent, "\r\n");
+                assertEquals(
+                        "parent test template output",
+                        templateContentLicenseRemoved);
+                assertEquals(0, generator.getMergepointMappings().size());
+            }
+        }
+    }
+
+    private static void assertSourcesEquals(
+            FileSourcesImpl expected,
+            FileSourcesImpl actual)
+    {
+        if (expected.getSourceFilter() != null)
+        {
+            assertEquals(
+                    expected.getSourceFilter().getClass(),
+                    actual.getSourceFilter().getClass());
+        }
+        else
+        {
+            assertNull(actual.getSourceFilter());
+        }
+        assertEquals(
+                expected.getStartElementsPath(),
+                actual.getStartElementsPath());
+        assertEquals(
+                expected.getTransformerDefinitions(),
+                actual.getTransformerDefinitions());
+        assertEquals(
+                expected.getType(),
+                actual.getType());
+        assertEquals(
+                expected.getPath(),
+                actual.getPath());
+        assertEquals(
+                expected.getPaths(),
+                actual.getPaths());
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/DeeplyNestedMergepointsTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/DeeplyNestedMergepointsTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/DeeplyNestedMergepointsTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/DeeplyNestedMergepointsTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,73 @@
+package org.apache.torque.gf.control;
+
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.torque.gf.BaseTest;
+import org.apache.torque.gf.configuration.UnitDescriptor;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
+import org.junit.Test;
+
+/**
+ * Tests nested mergepoints in a depth of 10 calls, and checks that the
+ * outcome is correct.
+ */
+public class DeeplyNestedMergepointsTest extends BaseTest
+{
+    @Test
+    public void testDeeplyNestedMergepointsGeneration() throws Exception
+    {
+        File targetDir = new File("src/test/deeplyNestedMergepoints/target");
+        FileUtils.deleteDirectory(targetDir);
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+        unitDescriptors.add(new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                new Maven2DirectoryProjectPaths(new File("src/test/deeplyNestedMergepoints")),
+                new DefaultTorqueGfPaths()));
+        controller.run(unitDescriptors);
+
+        assertTrue(targetDir.exists());
+        File targetFile= new File(targetDir, "generated-sources/output.txt");
+        assertTrue(targetFile.exists());
+
+        FileReader fileReader = new FileReader(targetFile);
+        StringBuilder content = new StringBuilder();
+        int readChars;
+        char[] buffer = new char[50];
+        do {
+            readChars = fileReader.read(buffer);
+            if (readChars != -1) {
+                content.append(buffer, 0, readChars);
+            }
+        }
+        while (readChars != -1);
+        assertEquals("content", content.toString());
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaGenerationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaGenerationTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaGenerationTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaGenerationTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,53 @@
+package org.apache.torque.gf.control;
+
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.torque.gf.BaseTest;
+import org.apache.torque.gf.configuration.UnitDescriptor;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
+import org.junit.Test;
+
+public class PropertyToJavaGenerationTest extends BaseTest
+{
+    @Test
+    public void testPropertyToJavaGeneration() throws Exception
+    {
+        File target = new File("src/test/propertyToJava/target");
+        FileUtils.deleteDirectory(target);
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+        unitDescriptors.add(new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                new Maven2DirectoryProjectPaths(new File("src/test/propertyToJava")),
+                new DefaultTorqueGfPaths()));
+        controller.run(unitDescriptors);
+        // TODO: check outcome against reference file
+        assertTrue(target.exists());
+        // TODO: check generated-sources dir
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaJarGenerationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaJarGenerationTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaJarGenerationTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/PropertyToJavaJarGenerationTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,54 @@
+package org.apache.torque.gf.control;
+
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.torque.gf.BaseTest;
+import org.apache.torque.gf.configuration.UnitDescriptor;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2JarProjectPaths;
+import org.junit.Test;
+
+
+public class PropertyToJavaJarGenerationTest extends BaseTest
+{
+    @Test
+    public void testPropertyToJavaJarGeneration() throws Exception
+    {
+        File target = new File("target/test/propertyToJavaJar/target");
+        FileUtils.deleteDirectory(target);
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+        unitDescriptors.add(new UnitDescriptor(
+                UnitDescriptor.Packaging.JAR,
+                new Maven2JarProjectPaths(
+                        new File("target/test/propertyToJavaJar"),
+                        "propertyToJava.jar"),
+                new DefaultTorqueGfPaths()));
+        controller.run(unitDescriptors);
+        assertTrue(target.exists());
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/TokenReplacerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/TokenReplacerTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/TokenReplacerTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/control/TokenReplacerTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,142 @@
+package org.apache.torque.gf.control;
+
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import org.apache.torque.gf.BaseTest;
+import org.apache.torque.gf.configuration.UnitConfiguration;
+import org.apache.torque.gf.option.Option;
+import org.apache.torque.gf.option.OptionImpl;
+import org.apache.torque.gf.option.Options;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TokenReplacerTest extends BaseTest
+{
+    private TokenReplacer tokenReplacer;
+
+    @Before
+    public void setUp()
+    {
+        Options options = new Options();
+        {
+            Option optionWithoutNamespace = new OptionImpl(
+                    "optionWithoutNamespace",
+                    "ValueWithoutNamespace");
+            options.setGlobalOption(optionWithoutNamespace);
+        }
+        {
+            Option optionWithNamespace = new OptionImpl(
+                    "org.apache.torque.gf.optionWithNamespace",
+                    "ValueWithNamespace");
+            options.setGlobalOption(optionWithNamespace);
+        }
+        {
+            Option optionWithSpecialChars = new OptionImpl(
+                    "opt${}i\\on",
+                    "ValueWith${}Special\\Chars");
+            options.setGlobalOption(optionWithSpecialChars);
+        }
+
+        UnitConfiguration unitConfiguration = new UnitConfiguration();
+        unitConfiguration.setOptions(options);
+        ControllerState controllerState = new ControllerState();
+        controllerState.setUnitConfiguration(unitConfiguration);
+        tokenReplacer = new TokenReplacer(controllerState);
+    }
+
+    @Test
+    public void testNoToken() throws Exception
+    {
+        String input = "No Token in this String";
+        String output = tokenReplacer.process(input);
+        assertEquals(input, output);
+    }
+
+    @Test
+    public void testTokenWithoutNamespace() throws Exception
+    {
+        String input = "Prefix${option:optionWithoutNamespace}Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("PrefixValueWithoutNamespacePostfix", output);
+    }
+
+    @Test
+    public void testTokenWithNamespace() throws Exception
+    {
+        String input
+            = "Prefix${option:org.apache.torque.gf.optionWithNamespace}Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("PrefixValueWithNamespacePostfix", output);
+    }
+
+    @Test
+    public void testEscapingOutsideToken() throws Exception
+    {
+        String input = "Pre\\fixXXXPostfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("PrefixXXXPostfix", output);
+    }
+
+    @Test
+    public void testEscapingInToken() throws Exception
+    {
+        String input
+                = "Prefix${option:option\\W\\ithoutNamespace}Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("PrefixValueWithoutNamespacePostfix", output);
+    }
+
+    @Test
+    public void testDoubleEscapingOutsideToken() throws Exception
+    {
+        String input = "Prefix\\\\Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("Prefix\\Postfix", output);
+    }
+
+    @Test
+    public void testTokenWithSpecialChars() throws Exception
+    {
+        String input
+                = "Prefix${option:opt${\\}i\\\\on}Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("PrefixValueWith${}Special\\CharsPostfix", output);
+    }
+
+    @Test
+    public void testEscapingTokenStart1() throws Exception
+    {
+        String input
+                = "Prefix\\${XXX}Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("Prefix${XXX}Postfix", output);
+    }
+
+    @Test
+    public void testEscapingTokenStart2() throws Exception
+    {
+        String input
+                = "Prefix$\\{XXX}Postfix";
+        String output = tokenReplacer.process(input);
+        assertEquals("Prefix${XXX}Postfix", output);
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStarted.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStarted.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStarted.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStarted.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,47 @@
+package org.apache.torque.gf.example.gettingstarted;
+
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.torque.gf.configuration.UnitDescriptor;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
+import org.apache.torque.gf.control.Controller;
+
+public class GettingStarted
+{
+    public static void main(String[] argv) throws Exception
+    {
+        File target = new File("target");
+        FileUtils.deleteDirectory(target);
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+        unitDescriptors.add(new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                new Maven2DirectoryProjectPaths(
+                        new File(".")),
+                new DefaultTorqueGfPaths()));
+        controller.run(unitDescriptors);
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStartedTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStartedTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStartedTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/example/gettingstarted/GettingStartedTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,62 @@
+package org.apache.torque.gf.example.gettingstarted;
+
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.torque.gf.BaseTest;
+import org.apache.torque.gf.configuration.UnitDescriptor;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
+import org.apache.torque.gf.control.Controller;
+import org.junit.Test;
+
+public class GettingStartedTest extends BaseTest
+{
+    @Test
+    public void testGettingStarted() throws Exception
+    {
+        File target = new File("src/test/site/gettingStarted/target");
+        FileUtils.deleteDirectory(target);
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+        unitDescriptors.add(new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                new Maven2DirectoryProjectPaths(
+                        new File("src/test/site/gettingStarted")),
+                new DefaultTorqueGfPaths()));
+        controller.run(unitDescriptors);
+        assertTrue(target.exists());
+        File generatedJavaFile = new File(
+                target,
+                "generated-sources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java");
+        assertTrue(generatedJavaFile.exists());
+        File expectedJavaFile = new File(
+                "src/test/resources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java");
+        junitx.framework.FileAssert.assertEquals(
+                expectedJavaFile,
+                generatedJavaFile);
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/ModifySourcenameGeneratorTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/ModifySourcenameGeneratorTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/ModifySourcenameGeneratorTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/ModifySourcenameGeneratorTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,98 @@
+package org.apache.torque.gf.generator.java;
+
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import java.io.File;
+
+import org.apache.torque.gf.control.ControllerState;
+import org.apache.torque.gf.generator.GeneratorException;
+import org.apache.torque.gf.qname.QualifiedName;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ModifySourcenameGeneratorTest
+{
+    private ModifySourcenameGenerator generator;
+
+    private ControllerState controllerState;
+
+    @Before
+    public void setUp()
+    {
+        this.generator = new ModifySourcenameGenerator(new QualifiedName(
+                "org.apache.torque.gf.modifySourcenameGenerator"));
+        controllerState = new ControllerState();
+        controllerState.setSourceFile(
+                new File("src/test/some-test-file-name.someTestExtension"));
+    }
+
+    @Test
+    public void testDefault() throws GeneratorException
+    {
+        String result = generator.execute(controllerState);
+        assertEquals("some-test-file-name.someTestExtension", result);
+    }
+
+    @Test
+    public void testAll() throws GeneratorException
+    {
+        generator.setDiscardFrom("Ext");
+        generator.setDiscardTo("me-");
+        generator.setPrefix("prefix-");
+        generator.setSuffix("-suffix");
+        String result = generator.execute(controllerState);
+        assertEquals("prefix-test-file-name.someTest-suffix", result);
+    }
+
+    @Test
+    public void testDiscardFrom() throws GeneratorException
+    {
+        generator.setDiscardFrom("-");
+        String result = generator.execute(controllerState);
+        assertEquals("some", result);
+    }
+
+    @Test
+    public void testDiscardTo() throws GeneratorException
+    {
+        generator.setDiscardTo("-");
+        String result = generator.execute(controllerState);
+        assertEquals("name.someTestExtension", result);
+    }
+
+    @Test
+    public void testOverlappingFromAndTo() throws GeneratorException
+    {
+        generator.setDiscardFrom("-");
+        generator.setDiscardTo("-");
+        String result = generator.execute(controllerState);
+        assertEquals("", result);
+    }
+
+    @Test
+    public void testSourceFilenameNull() throws GeneratorException
+    {
+        controllerState.setSourceFile(null);
+        String result = generator.execute(controllerState);
+        assertEquals("", result);
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/NewlineGeneratorTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/NewlineGeneratorTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/NewlineGeneratorTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/generator/java/NewlineGeneratorTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,73 @@
+package org.apache.torque.gf.generator.java;
+
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import org.apache.torque.gf.generator.GeneratorException;
+import org.apache.torque.gf.qname.QualifiedName;
+import org.junit.Before;
+import org.junit.Test;
+
+public class NewlineGeneratorTest
+{
+    private NewlineGenerator newlineGenerator;
+
+    @Before
+    public void setUp()
+    {
+        this.newlineGenerator = new NewlineGenerator(new QualifiedName(
+                "org.apache.torque.gf.newlineGenerator"));
+    }
+
+    @Test
+    public void testDefault() throws GeneratorException {
+        String result = newlineGenerator.execute(null);
+        assertEquals("\n", result);
+    }
+
+    @Test
+    public void testWindowsStyle() throws GeneratorException {
+        newlineGenerator.setWindowsStyle(true);
+        String result = newlineGenerator.execute(null);
+        assertEquals("\r\n", result);
+    }
+
+    @Test()
+    public void testCountZero() throws GeneratorException {
+        newlineGenerator.setCount(0);
+        String result = newlineGenerator.execute(null);
+        assertEquals("", result);
+    }
+
+    @Test(expected = GeneratorException.class)
+    public void testCountLessThanZero() throws GeneratorException {
+        newlineGenerator.setCount(-1);
+        String result = newlineGenerator.execute(null);
+        assertEquals("\n", result);
+    }
+
+    @Test()
+    public void testCountFive() throws GeneratorException {
+        newlineGenerator.setCount(5);
+        String result = newlineGenerator.execute(null);
+        assertEquals("\n\n\n\n\n", result);
+    }
+}



---------------------------------------------------------------------
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