db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1470235 [4/7] - in /db/torque/torque4/trunk: torque-generator/ torque-generator/src/main/java/org/apache/torque/generator/configuration/ torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/ torque-generator/src/...
Date Sat, 20 Apr 2013 21:23:42 GMT
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/groovy/TorqueGenGroovy.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/groovy/TorqueGenGroovy.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/groovy/TorqueGenGroovy.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/groovy/TorqueGenGroovy.java Sat Apr 20 21:23:39 2013
@@ -21,12 +21,10 @@ package org.apache.torque.generator.temp
 
 import java.io.File;
 import java.util.Date;
-import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.generator.GeneratorException;
 import org.apache.torque.generator.control.ControllerState;
-import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.variable.Variable;
 
 /**
@@ -39,12 +37,12 @@ public class TorqueGenGroovy
     /**
      * The state of the controller in which this generator interface is used.
      */
-    private ControllerState controllerState;
+    private final ControllerState controllerState;
 
     /**
      * The outlet in which context this class is used.
      */
-    private GroovyOutlet outlet;
+    private final GroovyOutlet outlet;
 
     /**
      * A counter which can be used in velocity templates.
@@ -61,8 +59,8 @@ public class TorqueGenGroovy
      * @throws NullPointerException if outlet or controllerState are null.
      */
     public TorqueGenGroovy(
-            GroovyOutlet outlet,
-            ControllerState controllerState)
+            final GroovyOutlet outlet,
+            final ControllerState controllerState)
     {
         if (controllerState == null)
         {
@@ -84,7 +82,7 @@ public class TorqueGenGroovy
      * @throws GeneratorException if the mergepoint could not be processed
      *         completely.
      */
-    public String mergepoint(String mergepointName)
+    public String mergepoint(final String mergepointName)
         throws GeneratorException
     {
         return outlet.mergepoint(mergepointName, controllerState);
@@ -101,69 +99,33 @@ public class TorqueGenGroovy
     }
 
     /**
-     * Returns the current source element. This method is shorthand for
-     * <code>getControllerState().getSourceElement()</code>
+     * Returns the current model. This method is shorthand for
+     * <code>getControllerState().getModel()</code>
      *
      * @return the current source element, never null.
      */
-    public SourceElement getSourceElement()
+    public Object getModel()
     {
-        return controllerState.getSourceElement();
+        return controllerState.getModel();
     }
 
     /**
-     * Returns all children of the current source element.
-     * This method is shorthand for
-     * <code>getSourceElement().getChildren()</code>
-     *
-     * @return the children of the current source element, never null.
-     */
-    public List<SourceElement> getChildren()
-    {
-        return getSourceElement().getChildren();
-    }
-
-    /**
-     * Returns the children of the current source element with a certain name.
-     * This method is shorthand for
-     * <code>getSourceElement().getChildren(name)</code>
-     *
-     * @param name the name of the children elements to select.
-     *
-     * @return the children of the current source element with the name name,
-     *         never null.
-     */
-    public List<SourceElement> getChildren(String name)
-    {
-        return getSourceElement().getChildren(name);
-    }
-
-    /**
-     * Returns the first child of the current source element
-     * with the given name.
-     * This method is shorthand for
-     * <code>getSourceElement().getChild(name)</code>
+     * Returns the option with the given key. The key can either be a name
+     * prefixed with a namespace, or a name without namespace, in which case
+     * the namespace of the currently active outlet is used.
      *
-     * @param name the name of the child element to select.
+     * In the case that the option is not set in this namespace, the parent
+     * namespaces are searched recursively.  If the option is not set in any
+     * of the parent namespaces, null is returned.
      *
-     * @return the first child with the given name, or null if no such child
-     *         exists.
+     * @param key the key for the option to retrieve.
+     * @return the option for the given key.
      */
-    public SourceElement getChild(String name)
+    public Object option(final String key)
     {
-        return getSourceElement().getChild(name);
-    }
+        final Object result = controllerState.getOption(key);
 
-    /**
-     * Returns the parent of the current source element.
-     * <code>getSourceElement().getParent()</code>
-     *
-     * @return the parent of the current source element, or null if the current
-     *         source element has no parent.
-     */
-    public SourceElement getParent()
-    {
-        return getSourceElement().getParent();
+        return result;
     }
 
     /**
@@ -178,9 +140,9 @@ public class TorqueGenGroovy
      * @param key the key for the option to retrieve.
      * @return the option for the given key.
      */
-    public Object option(String key)
+    public Object getOption(final String key)
     {
-        Object result = controllerState.getOption(key);
+        final Object result = controllerState.getOption(key);
 
         return result;
     }
@@ -198,9 +160,9 @@ public class TorqueGenGroovy
      * @param key the key for the option to retrieve.
      * @return the option for the given key, converted to a boolean
      */
-    public boolean booleanOption(String key)
+    public boolean booleanOption(final String key)
     {
-        boolean result = controllerState.getBooleanOption(key);
+        final boolean result = controllerState.getBooleanOption(key);
 
         return result;
     }
@@ -218,14 +180,14 @@ public class TorqueGenGroovy
      * @param key the key for the option to retrieve.
      * @return the option for the given key, converted to a boolean
      */
-    public int intOption(String key)
+    public int intOption(final String key)
     {
-        Object optionValue = controllerState.getOption(key);
+        final Object optionValue = controllerState.getOption(key);
         if (optionValue == null)
         {
             return 0;
         }
-        String optionString = optionValue.toString();
+        final String optionString = optionValue.toString();
         if (StringUtils.isBlank(optionString))
         {
             return 0;
@@ -247,7 +209,7 @@ public class TorqueGenGroovy
      * @return the variable for the given key, or null if the variable is not
      *         set or explicitly set to null.
      */
-    public Object getVariable(String key)
+    public Object getVariable(final String key)
     {
         return outlet.getVariable(key, controllerState);
     }
@@ -264,7 +226,7 @@ public class TorqueGenGroovy
      * @throws NullPointerException if key or scope is null.
      * @throws IllegalArgumentException if the key is no valid QualifiedName.
      */
-    public void setVariable(String key, Object value)
+    public void setVariable(final String key, final Object value)
     {
         outlet.setVariable(key, value, controllerState);
     }
@@ -281,9 +243,9 @@ public class TorqueGenGroovy
      * @throws NullPointerException if key or scope is null.
      * @throws IllegalArgumentException if the key is no valid QualifiedName.
      */
-    public void setVariable(String key, Object value, String scope)
+    public void setVariable(final String key, final Object value, final String scope)
     {
-        Variable.Scope scopeValue = Variable.Scope.valueOf(scope);
+        final Variable.Scope scopeValue = Variable.Scope.valueOf(scope);
         outlet.setVariable(key, value, scopeValue, controllerState);
     }
 

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/TorqueGenVelocity.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/TorqueGenVelocity.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/TorqueGenVelocity.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/TorqueGenVelocity.java Sat Apr 20 21:23:39 2013
@@ -27,6 +27,7 @@ import org.apache.commons.lang.StringUti
 import org.apache.torque.generator.GeneratorException;
 import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.source.SourceElement;
+import org.apache.torque.generator.source.SourceException;
 import org.apache.torque.generator.variable.Variable;
 
 /**
@@ -101,14 +102,34 @@ public class TorqueGenVelocity
     }
 
     /**
-     * Returns the current source element. This method is shorthand for
-     * <code>getControllerState().getSourceElement()</code>
+     * Returns the current model object. This method is shorthand for
+     * <code>getControllerState().getModel()</code>
      *
      * @return the current source element, never null.
      */
-    public SourceElement getSourceElement()
+    public Object getModel()
     {
-        return controllerState.getSourceElement();
+        return controllerState.getModel();
+    }
+
+    /**
+     * Returns the current source element, if it is a SourceElement.
+     * This method is shorthand for
+     * <code>(SourceElement)getControllerState().getModel()</code>
+     *
+     * @return the current source element, never null.
+     *
+     * @throws SourceException if the model is no SourceElement
+     */
+    public SourceElement getSourceElement() throws SourceException
+    {
+        Object model = controllerState.getModel();
+        if (model instanceof SourceElement)
+        {
+            return (SourceElement) model;
+        }
+        throw new SourceException("model is no SourceElement but is of class "
+        + model.getClass().getName());
     }
 
     /**
@@ -117,8 +138,10 @@ public class TorqueGenVelocity
      * <code>getSourceElement().getChildren()</code>
      *
      * @return the children of the current source element, never null.
+     *
+     * @throws SourceException if the model is no SourceElement
      */
-    public List<SourceElement> getChildren()
+    public List<SourceElement> getChildren() throws SourceException
     {
         return getSourceElement().getChildren();
     }
@@ -132,8 +155,10 @@ public class TorqueGenVelocity
      *
      * @return the children of the current source element with the name name,
      *         never null.
+     *
+     * @throws SourceException if the model is no SourceElement
      */
-    public List<SourceElement> getChildren(String name)
+    public List<SourceElement> getChildren(String name) throws SourceException
     {
         return getSourceElement().getChildren(name);
     }
@@ -148,8 +173,10 @@ public class TorqueGenVelocity
      *
      * @return the first child with the given name, or null if no such child
      *         exists.
+     *
+     * @throws SourceException if the model is no SourceElement
      */
-    public SourceElement getChild(String name)
+    public SourceElement getChild(String name) throws SourceException
     {
         return getSourceElement().getChild(name);
     }
@@ -160,8 +187,10 @@ public class TorqueGenVelocity
      *
      * @return the parent of the current source element, or null if the current
      *         source element has no parent.
+     *
+     * @throws SourceException if the model is no SourceElement
      */
-    public SourceElement getParent()
+    public SourceElement getParent() throws SourceException
     {
         return getSourceElement().getParent();
     }

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java Sat Apr 20 21:23:39 2013
@@ -230,20 +230,6 @@ public class VelocityOutlet extends Temp
                         e);
             }
 
-            SourceElement sourceElement = controllerState.getSourceElement();
-
-            String inputElementName = getInputElementName();
-            if (inputElementName != null
-                    && !inputElementName.equals(sourceElement.getName()))
-            {
-                throw new GeneratorException("Input element name, "
-                        + sourceElement.getName()
-                        + ", is not the expected name, "
-                        + getInputElementName()
-                        + ", for outlet "
-                        + getName());
-            }
-
             Context context = createVelocityContext(controllerState);
 
             Writer writer = new StringWriter();
@@ -314,8 +300,13 @@ public class VelocityOutlet extends Temp
             log.debug("options in context are disabled");
         }
 
-        SourceElement sourceElement = controllerState.getSourceElement();
-        if (sourceAttributesInContext)
+        Object model = controllerState.getModel();
+        SourceElement sourceElement = null;
+        if (model instanceof SourceElement)
+        {
+            sourceElement = (SourceElement) model;
+        }
+        if (sourceAttributesInContext && sourceElement != null)
         {
             Set<String> attributes = sourceElement.getAttributeNames();
             for (String key : attributes)

Modified: db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd Sat Apr 20 21:23:39 2013
@@ -198,14 +198,6 @@
         </documentation>
       </annotation>
     </attribute>
-    <attribute name="modelRootClass" type="string" use="optional">
-      <annotation>
-        <documentation>
-          The fully qualified name of the class to construct from the root
-          element.
-        </documentation>
-      </annotation>
-    </attribute>
     <attribute name="skipDecider" type="string" use="optional">
       <annotation>
         <documentation>
@@ -287,15 +279,6 @@
         </documentation>
       </annotation>
     </attribute>
-    <attribute name="elements" type="string" use="optional">
-      <annotation>
-        <documentation>
-          The path to source elements to which the transformer is applied.
-          If not set, the transformer is applied to the root element
-          of the source.
-        </documentation>
-      </annotation>
-    </attribute>
   </complexType>
 
   <complexType name="outletReference">

Modified: db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd Sat Apr 20 21:23:39 2013
@@ -83,6 +83,13 @@
         <attribute name="sourceAttributesInBinding" type="string" use="optional"/>
         <attribute name="variablesInBinding" type="string" use="optional"/>
         <attribute name="encoding" type="string" use="optional"/>
+        <!-- 
+          Whether the outlet is a script(false) or template (true) 
+          If not set, the type is retrieved from the path ending. 
+          If the path ends with ".groovy" it is a script,
+          in all other cases it is a template;
+          -->
+        <attribute name="template" type="boolean" use="optional"/>
       </extension>
     </complexContent>
   </complexType>
@@ -105,7 +112,9 @@
   </complexType>
   
   <complexType name="input">
-    <attribute name="elementName" use="required" />
+    <!-- Exactly one of the attributes must be set -->
+    <attribute name="elementName" use="optional" />
+    <attribute name="class" use="optional" />
   </complexType>
 
   <complexType name="mergepoint">

Modified: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -43,8 +43,7 @@
         format="xml"
         combineFiles="false"
         skipDecider="org.apache.torque.generator.configuration.OtherConfigurationTestSkipDecider">
-      <transformer elements="parent/database" 
-          class="org.apache.torque.generator.configuration.OtherConfigurationTestTransformer" />
+      <transformer class="org.apache.torque.generator.configuration.OtherConfigurationTestTransformer" />
       <include>parentSource</include>
     </source>
     <outlet name="org.apache.torque.generator.test.readConfiguration.testParentOutlet"/>
@@ -54,8 +53,7 @@
     <source xsi:type="fileSource"
         format="properties"
         skipDecider="org.apache.torque.generator.configuration.OtherConfigurationTestSkipDecider">
-      <transformer elements="second/parent/database" 
-          class="org.apache.torque.generator.configuration.ConfigurationTestTransformer" />
+      <transformer class="org.apache.torque.generator.configuration.ConfigurationTestTransformer" />
       <include>secondParentSource</include>
       <exclude>secondParentExclude</exclude>
     </source>

Modified: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -50,8 +50,7 @@
         combineFiles="true"
         skipDecider="org.apache.torque.generator.configuration.ConfigurationTestSkipDecider">
       <transformer class="org.apache.torque.generator.configuration.ConfigurationTestTransformer" />
-      <transformer elements="database" 
-          class="org.apache.torque.generator.configuration.OtherConfigurationTestTransformer" />
+      <transformer class="org.apache.torque.generator.configuration.OtherConfigurationTestTransformer" />
       <include>second.source.path.properties</include>
       <exclude>second.excluded.properties</exclude>
     </source>

Modified: db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -23,7 +23,7 @@
     xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration http://db.apache.org/torque/4.0/generator/configuration.xsd"
     xmlns="http://db.apache.org/torque/4.0/generator/configuration">
   <output name="output" file="output.txt">
-    <source xsi:type="fileSource" elements="sourceElement" format="xml">
+    <source xsi:type="fileSource" elements="/" format="xml">
       <include>source.xml</include>
     </source>
     <outlet name="nestingOutlet0"/>

Modified: db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/appendStrategy/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/appendStrategy/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/appendStrategy/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/appendStrategy/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -24,13 +24,13 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration"
     loglevel="debug">
   <output name="output1" file="output1.txt" existingTargetStrategy="append">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source1.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />
   </output>
   <output name="output2" file="output2.txt" existingTargetStrategy="append" outputDirKey="outputDirKey2">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source2.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />

Modified: db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/initial/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/initial/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/initial/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/initial/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -24,13 +24,13 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration"
     loglevel="debug">
   <output name="output1" file="output1.txt">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source1.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />
   </output>
   <output name="output2" file="output2.txt" outputDirKey="outputDirKey2">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source2.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />

Modified: db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/mergeStrategy/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/mergeStrategy/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/mergeStrategy/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/mergeStrategy/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -24,13 +24,13 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration"
     loglevel="debug">
   <output name="output1" file="output1.txt" existingTargetStrategy="merge">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source1.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />
   </output>
   <output name="output2" file="output2.txt" existingTargetStrategy="merge" outputDirKey="outputDirKey2">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source2.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />

Modified: db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/replaceStrategy/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/replaceStrategy/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/replaceStrategy/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/replaceStrategy/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -24,13 +24,13 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration"
     loglevel="debug">
   <output name="output1" file="output1.txt">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source1.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />
   </output>
   <output name="output2" file="output2.txt" existingTargetStrategy="replace" outputDirKey="outputDirKey2">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source2.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />

Modified: db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/skipStrategy/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/skipStrategy/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/skipStrategy/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/existingTargetStrategy/skipStrategy/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -24,13 +24,13 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration"
     loglevel="debug">
   <output name="output1" file="output1.txt" existingTargetStrategy="skip">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source1.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />
   </output>
   <output name="output2" file="output2.txt" existingTargetStrategy="skip" outputDirKey="outputDirKey2">
-    <source xsi:type="fileSource" elements="properties">
+    <source xsi:type="fileSource" elements="/">
       <include>source2.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy" />

Modified: db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/conf/control.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/conf/control.xml Sat Apr 20 21:23:39 2013
@@ -22,11 +22,17 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration http://db.apache.org/torque/4.0/generator/configuration.xsd"
     xmlns="http://db.apache.org/torque/4.0/generator/configuration">
-  <output name="output" file="output.txt">
-    <source xsi:type="fileSource" elements="root" format="xml">
+  <output name="templateOutput" file="templateOutput.txt">
+    <source xsi:type="fileSource" elements="/" format="xml">
       <include>source.xml</include>
     </source>
-    <outlet name="testGroovyOutlet"/>
+    <outlet name="groovyTemplate"/>
+  </output>
+  <output name="scriptOutput" file="scriptOutput.txt">
+    <source xsi:type="fileSource" elements="/" format="xml">
+      <include>source.xml</include>
+    </source>
+    <outlet name="groovyScript"/>
   </output>
 </control>
   
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/outlets/outlets.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/outlets/outlets.xml?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/outlets/outlets.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/outlets/outlets.xml Sat Apr 20 21:23:39 2013
@@ -22,8 +22,10 @@
     xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration http://db.apache.org/torque/4.0/generator/configuration.xsd"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
-  <outlet name="testGroovyOutlet"
+  <outlet name="groovyTemplate"
       xsi:type="groovyOutlet"
-      path="template.gtl">
-  </outlet>
+      path="template.gtl"/>
+  <outlet name="groovyScript"
+      xsi:type="groovyOutlet"
+      path="template.groovy"/>
 </outlets>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.groovy?rev=1470235&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.groovy (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.groovy Sat Apr 20 21:23:39 2013
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */ 
+return "groovy script output: ${torqueGen.getModel().getName()}"
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.gtl
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.gtl?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.gtl (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/groovyTemplates/src/main/torque-gen/templates/template.gtl Sat Apr 20 21:23:39 2013
@@ -16,4 +16,4 @@
  * specific language governing permissions and limitations
  * under the License.
  */ 
-%>groovy template output: ${torqueGen.getSourceElement().getName()}
\ No newline at end of file
+%>groovy template output: ${torqueGen.getModel().getName()}
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ConfigurationTestTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ConfigurationTestTransformer.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ConfigurationTestTransformer.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ConfigurationTestTransformer.java Sat Apr 20 21:23:39 2013
@@ -20,7 +20,6 @@ package org.apache.torque.generator.conf
  */
 
 import org.apache.torque.generator.control.ControllerState;
-import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.transform.SourceTransformer;
 import org.apache.torque.generator.source.transform.SourceTransformerException;
 
@@ -31,7 +30,7 @@ import org.apache.torque.generator.sourc
  */
 public class ConfigurationTestTransformer implements SourceTransformer
 {
-    public SourceElement transform(SourceElement toTransformRoot,
+    public Object transform(Object toTransformRoot,
             ControllerState controllerState) throws SourceTransformerException
     {
         return toTransformRoot;

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/OtherConfigurationTestTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/OtherConfigurationTestTransformer.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/OtherConfigurationTestTransformer.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/OtherConfigurationTestTransformer.java Sat Apr 20 21:23:39 2013
@@ -20,7 +20,6 @@ package org.apache.torque.generator.conf
  */
 
 import org.apache.torque.generator.control.ControllerState;
-import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.transform.SourceTransformer;
 import org.apache.torque.generator.source.transform.SourceTransformerException;
 
@@ -31,7 +30,7 @@ import org.apache.torque.generator.sourc
  */
 public class OtherConfigurationTestTransformer implements SourceTransformer
 {
-    public SourceElement transform(SourceElement toTransformRoot,
+    public Object transform(Object toTransformRoot,
             ControllerState controllerState) throws SourceTransformerException
     {
         return toTransformRoot;

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java Sat Apr 20 21:23:39 2013
@@ -307,12 +307,10 @@ public class ReadConfigurationTest exten
 
                     transformerDefinitions.add(
                             new SourceTransformerDefinition(
-                                    new ConfigurationTestTransformer(),
-                                    null));
+                                    new ConfigurationTestTransformer()));
                     transformerDefinitions.add(
                             new SourceTransformerDefinition(
-                                    new OtherConfigurationTestTransformer(),
-                                    "database"));
+                                    new OtherConfigurationTestTransformer()));
                     sourceProcessConfiguration.setSourceTransformerDefinitions(
                             transformerDefinitions);
                     sourceProcessConfiguration.setSkipDecider(
@@ -397,7 +395,6 @@ public class ReadConfigurationTest exten
                                     "org.apache.torque.generator.velocity.propertyCopy",
                                     true),
                             action);
-                    assertEquals("inputElement", outlet.getInputElementName());
                 }
                 {
                     // mergepoint from the separate mapping
@@ -412,7 +409,6 @@ public class ReadConfigurationTest exten
                                     "someOutletAction",
                                     false),
                             action);
-                    assertEquals("inputElement", outlet.getInputElementName());
                 }
                 {
                     // other mergepoint from the separate mapping
@@ -427,7 +423,6 @@ public class ReadConfigurationTest exten
                                     "newOutletAction",
                                     true),
                             action);
-                    assertEquals("inputElement", outlet.getInputElementName());
                 }
             }
 
@@ -445,7 +440,6 @@ public class ReadConfigurationTest exten
                         "test template output",
                         templateContentLicenseRemoved);
                 assertEquals(0, outlet.getMergepointMappings().size());
-                assertNull(outlet.getInputElementName());
                 assertFalse(outlet.isOptionsInContext());
                 assertFalse(outlet.isSourceAttributesInContext());
                 assertFalse(outlet.isVariablesInContext());
@@ -712,8 +706,7 @@ public class ReadConfigurationTest exten
 
                     transformerDefinitions.add(
                             new SourceTransformerDefinition(
-                                    new OtherConfigurationTestTransformer(),
-                                    "parent/database"));
+                                    new OtherConfigurationTestTransformer()));
                     sourceProcessConfiguration.setSourceTransformerDefinitions(
                             transformerDefinitions);
                     sourceProcessConfiguration.setSkipDecider(
@@ -846,12 +839,10 @@ public class ReadConfigurationTest exten
                             = new ArrayList<SourceTransformerDefinition>();
                     transformerDefinitions.add(
                             new SourceTransformerDefinition(
-                                    new ConfigurationTestTransformer(),
-                                    null));
+                                    new ConfigurationTestTransformer()));
                     transformerDefinitions.add(
                             new SourceTransformerDefinition(
-                                    new OtherConfigurationTestTransformer(),
-                                    "database"));
+                                    new OtherConfigurationTestTransformer()));
                     sourceProcessConfiguration.setSourceTransformerDefinitions(
                             transformerDefinitions);
                     sourceProcessConfiguration.setSkipDecider(
@@ -936,7 +927,6 @@ public class ReadConfigurationTest exten
                                     "org.apache.torque.generator.velocity.propertyCopy",
                                     true),
                             action);
-                    assertEquals("inputElement", outlet.getInputElementName());
                 }
                 {
                     // mergepoint from the separate mapping in child
@@ -951,7 +941,6 @@ public class ReadConfigurationTest exten
                                     "someOutletAction",
                                     false),
                             action);
-                    assertEquals("inputElement", outlet.getInputElementName());
                 }
                 {
                     // other mergepoint from the separate mapping in child
@@ -966,7 +955,6 @@ public class ReadConfigurationTest exten
                                     "newOutletAction",
                                     true),
                             action);
-                    assertEquals("inputElement", outlet.getInputElementName());
                 }
             }
 

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/java/JavaOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/java/JavaOutlet.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/java/JavaOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/java/JavaOutlet.java Sat Apr 20 21:23:39 2013
@@ -83,9 +83,6 @@ public class JavaOutlet extends OutletIm
         result = prime * result + ((bar == null) ? 0 : bar.hashCode());
         result = prime * result + ((foo == null) ? 0 : foo.hashCode());
         result = prime * result + getName().hashCode();
-        result = prime * result + ((getInputElementName() == null)
-                ? 0
-                : getInputElementName().hashCode());
         return result;
     }
 
@@ -131,17 +128,6 @@ public class JavaOutlet extends OutletIm
         {
             return false;
         }
-        if (getInputElementName() == null)
-        {
-            if (other.getInputElementName() != null)
-            {
-                return false;
-            }
-        }
-        else if (!getInputElementName().equals(other.getInputElementName()))
-        {
-            return false;
-        }
         return true;
     }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java Sat Apr 20 21:23:39 2013
@@ -43,7 +43,7 @@ public class XmlOutletTest
         SourceElement rootElement = new SourceElement("root");
         rootElement.getChildren().add(new SourceElement("child"));
         ControllerState controllerState = new ControllerState();
-        controllerState.setRootElement(rootElement);
+        controllerState.setModelRoot(rootElement);
         XmlOutlet xmlOutlet = new XmlOutlet(new QualifiedName("test"));
         OutletResult result = xmlOutlet.execute(controllerState);
         assertEquals(
@@ -62,7 +62,7 @@ public class XmlOutletTest
         SourceElement rootElement = new SourceElement("root");
         rootElement.getChildren().add(new SourceElement("child"));
         ControllerState controllerState = new ControllerState();
-        controllerState.setRootElement(rootElement);
+        controllerState.setModelRoot(rootElement);
         XmlOutlet xmlOutlet = new XmlOutlet(new QualifiedName("test"));
         xmlOutlet.setCreateIdAttributes(true);
         OutletResult result = xmlOutlet.execute(controllerState);

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/SourcePathTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/SourcePathTest.java?rev=1470235&r1=1470234&r2=1470235&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/SourcePathTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/SourcePathTest.java Sat Apr 20 21:23:39 2013
@@ -20,9 +20,12 @@ package org.apache.torque.generator.sour
  */
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.torque.generator.GeneratorException;
@@ -36,7 +39,10 @@ public class SourcePathTest
     private SourceElement firstLevel2;
     private SourceElement firstLevel3;
     private SourceElement secondLevel;
+    private SourceElement secondLevela;
+    private SourceElement secondLevelb;
     private SourceElement thirdLevel;
+    private Root modelRoot;
 
     @Before
     public void setUp()
@@ -52,6 +58,22 @@ public class SourcePathTest
         firstLevel2.getChildren().add(secondLevel);
         thirdLevel = new SourceElement("thirdLevel");
         secondLevel.getChildren().add(thirdLevel);
+        secondLevela = new SourceElement("secondLevel");
+        firstLevel2.getChildren().add(secondLevela);
+        secondLevelb = new SourceElement("secondLevel");
+        firstLevel2.getChildren().add(secondLevelb);
+
+        modelRoot = new Root();
+        modelRoot.childList.add(new Child("child1"));
+        modelRoot.childList.add(new Child("child2"));
+        modelRoot.stringList.add("string1");
+        modelRoot.stringList.add("string2");
+        modelRoot.getPropertyList().add("propertyString1");
+        modelRoot.getPropertyList().add("propertyString2");
+        modelRoot.fieldValue = "fieldValue";
+        modelRoot.setPropertyValue("propertyValue");
+        modelRoot.setValue("setterValue");
+        modelRoot.value = "fieldValue";
     }
 
     @Test
@@ -65,8 +87,8 @@ public class SourcePathTest
     @Test(expected = GeneratorException.class)
     public void testGetPathInfiniteLoop() throws GeneratorException
     {
-        SourceElement loopElement1 = new SourceElement("loopElement1");
-        SourceElement loopElement2 = new SourceElement("loopElement2");
+        final SourceElement loopElement1 = new SourceElement("loopElement1");
+        final SourceElement loopElement2 = new SourceElement("loopElement2");
         loopElement1.getChildren().add(loopElement2);
         loopElement2.getChildren().add(loopElement1);
         SourcePath.getPathAsString(loopElement1);
@@ -75,9 +97,9 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootWithSlash()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "/");
-        List<SourceElement> expected = new ArrayList<SourceElement>();
+        final List<SourceElement> expected = new ArrayList<SourceElement>();
         expected.add(root);
         assertEquals(expected, result);
     }
@@ -85,9 +107,9 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootSingleRelativeElement()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "root");
-        List<SourceElement> expected = new ArrayList<SourceElement>();
+        final List<SourceElement> expected = new ArrayList<SourceElement>();
         expected.add(root);
         assertEquals(expected, result);
     }
@@ -95,7 +117,7 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootSingleRelativeElementNoMatch()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "root1");
         assertEquals(0, result.size());
     }
@@ -103,9 +125,9 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootSingleAbsoluteElement()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "/root");
-        List<SourceElement> expected = new ArrayList<SourceElement>();
+        final List<SourceElement> expected = new ArrayList<SourceElement>();
         expected.add(root);
         assertEquals(expected, result);
     }
@@ -113,7 +135,7 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootSingleAbsoluteElementNoMatch()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "/root1");
         assertEquals(0, result.size());
     }
@@ -121,9 +143,9 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootWildcardAtStart()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "/*");
-        List<SourceElement> expected = new ArrayList<SourceElement>();
+        final List<SourceElement> expected = new ArrayList<SourceElement>();
         expected.add(root);
         assertEquals(expected, result);
     }
@@ -131,10 +153,12 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootWildcardInMiddle()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getElementsFromRoot(root, "/root/*/secondLevel");
-        List<SourceElement> expected = new ArrayList<SourceElement>();
+        final List<SourceElement> expected = new ArrayList<SourceElement>();
         expected.add(secondLevel);
+        expected.add(secondLevela);
+        expected.add(secondLevelb);
         assertEquals(expected, result);
     }
 
@@ -152,10 +176,10 @@ public class SourcePathTest
     @Test
     public void testGetElementFromRootParentInMiddle()
     {
-        List<SourceElement> result = SourcePath.getElementsFromRoot(
+        final List<SourceElement> result = SourcePath.getElementsFromRoot(
                 root,
                 "/root/firstLevel1/../firstLevel2");
-        List<SourceElement> expected = new ArrayList<SourceElement>();
+        final List<SourceElement> expected = new ArrayList<SourceElement>();
         expected.add(firstLevel2);
         assertEquals(expected, result);
     }
@@ -163,7 +187,7 @@ public class SourcePathTest
     @Test
     public void testGetPreceding()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getPreceding(firstLevel2, "firstLevel1");
         assertEquals(1, result.size());
         assertSame(firstLevel1, result.get(0));
@@ -172,7 +196,7 @@ public class SourcePathTest
     @Test
     public void testGetPrecedingNoMatch()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getPreceding(firstLevel2, "firstLevel2");
         assertEquals(0, result.size());
     }
@@ -180,7 +204,7 @@ public class SourcePathTest
 
     public void testGetFollowing()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getFollowing(firstLevel2, "firstLevel3");
         assertEquals(1, result.size());
         assertSame(firstLevel3, result.get(0));
@@ -189,8 +213,168 @@ public class SourcePathTest
     @Test
     public void testGetFollowingNoMatch()
     {
-        List<SourceElement> result
+        final List<SourceElement> result
                 = SourcePath.getFollowing(firstLevel2, "firstLevel2");
         assertEquals(0, result.size());
     }
+
+    @Test
+    public void testIterateGetRoot()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(root, "/");
+        assertTrue(resultIt.hasNext());
+        assertSame(root, resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateGetChild()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(root, "firstLevel1");
+        assertTrue(resultIt.hasNext());
+        assertSame(firstLevel1, resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateSeveralMatches()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(root, "firstLevel2/secondLevel");
+        assertTrue(resultIt.hasNext());
+        assertSame(secondLevel, resultIt.next());
+        assertTrue(resultIt.hasNext());
+        assertSame(secondLevela, resultIt.next());
+        assertTrue(resultIt.hasNext());
+        assertSame(secondLevelb, resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    /**
+     * Test that we can iterate over path where the parent element
+     * of the mathcing elements is not the primary parent element.
+     */
+    @Test
+    public void testIterateNotDefaultParent()
+    {
+        firstLevel1.getChildren().add(secondLevela);
+        firstLevel1.getChildren().add(secondLevel);
+        final Iterator<?> resultIt = SourcePath.iterate(root, "firstLevel1/secondLevel");
+        assertTrue(resultIt.hasNext());
+        assertSame(secondLevela, resultIt.next());
+        assertTrue(resultIt.hasNext());
+        assertSame(secondLevel, resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateModelStringField()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(modelRoot, "fieldValue");
+        assertTrue(resultIt.hasNext());
+        assertEquals("fieldValue", resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateModelStringGetter()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(modelRoot, "propertyValue");
+        assertTrue(resultIt.hasNext());
+        assertEquals("propertyValue", resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateModelStringFieldAndGetter()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(modelRoot, "value");
+        assertTrue(resultIt.hasNext());
+        assertEquals("setterValue", resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateModelListField()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(modelRoot, "stringList");
+        assertTrue(resultIt.hasNext());
+        assertEquals("string1", resultIt.next());
+        assertTrue(resultIt.hasNext());
+        assertEquals("string2", resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateModelListProperty()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(modelRoot, "propertyList");
+        assertTrue(resultIt.hasNext());
+        assertEquals("propertyString1", resultIt.next());
+        assertTrue(resultIt.hasNext());
+        assertEquals("propertyString2", resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    @Test
+    public void testIterateModelListChainedAttribute()
+    {
+        final Iterator<?> resultIt = SourcePath.iterate(modelRoot, "childList/value");
+        assertTrue(resultIt.hasNext());
+        assertEquals("child1", resultIt.next());
+        assertTrue(resultIt.hasNext());
+        assertEquals("child2", resultIt.next());
+        assertFalse(resultIt.hasNext());
+    }
+
+    public static class Root
+    {
+        public List<String> stringList = new ArrayList<String>();
+
+        public List<Child> childList = new ArrayList<Child>();
+
+        private final List<String> propertyList = new ArrayList<String>();
+
+        public String fieldValue;
+
+        public String value;
+
+        private String setterValue;
+
+        private String propertyValue;
+
+        public List<String> getPropertyList()
+        {
+            return propertyList;
+        }
+
+        public String getPropertyValue()
+        {
+            return propertyValue;
+        }
+
+        public void setPropertyValue(final String v)
+        {
+            this.propertyValue = v;
+        }
+
+        public String getValue()
+        {
+            return setterValue;
+        }
+
+        public void setValue(final String v)
+        {
+            this.setterValue = v;
+        }
+    }
+
+    public static class Child
+    {
+        public Child(final String value)
+        {
+            this.value = value;
+        }
+
+        public String value;
+    }
 }



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