db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1368426 [2/2] - in /db/torque/torque4/trunk/torque-generator/src: main/java/org/apache/torque/generator/configuration/controller/ main/java/org/apache/torque/generator/configuration/outlet/ main/java/org/apache/torque/generator/control/ ma...
Date Thu, 02 Aug 2012 11:46:39 GMT
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=1368426&r1=1368425&r2=1368426&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
Thu Aug  2 11:46:37 2012
@@ -75,6 +75,14 @@
     </complexContent>
   </complexType>
   
+  <complexType name="copyOutlet">
+    <complexContent>
+      <extension base="configuration:baseOutlet">
+        <attribute name="path" type="string" use="required"/>
+      </extension>
+    </complexContent>
+  </complexType>
+  
   <!-- not yet implemented -->
   <complexType name="xalanOutlet">
     <complexContent>

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
Thu Aug  2 11:46:37 2012
@@ -19,6 +19,7 @@ package org.apache.torque.generator.cont
  * under the License.
  */
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -31,7 +32,6 @@ import org.apache.torque.generator.confi
 import org.apache.torque.generator.configuration.paths.CustomProjectPaths;
 import org.apache.torque.generator.configuration.paths.DefaultTorqueGeneratorPaths;
 import org.apache.torque.generator.configuration.paths.Maven2DirectoryProjectPaths;
-import org.apache.torque.generator.control.Controller;
 import org.junit.Test;
 
 public class PropertyToJavaGenerationTest extends BaseTest
@@ -54,5 +54,12 @@ public class PropertyToJavaGenerationTes
         controller.run(unitDescriptors);
         // TODO: check outcome against reference file
         assertTrue(targetDir.exists());
+        File logoResultFile = new File(targetDir, "logo.png");
+        assertTrue(logoResultFile.exists());
+        byte[] expectedContent = FileUtils.readFileToByteArray(
+            new File("src/test/propertyToJava/src/main/torque-gen/resources/torque-logo-new.png"));
+        assertArrayEquals(
+                expectedContent,
+                FileUtils.readFileToByteArray(logoResultFile));
     }
 }

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=1368426&r1=1368425&r2=1368426&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
Thu Aug  2 11:46:37 2012
@@ -24,10 +24,57 @@ import org.apache.commons.logging.LogFac
 import org.apache.torque.generator.GeneratorException;
 import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.outlet.OutletImpl;
+import org.apache.torque.generator.outlet.OutletResult;
 import org.apache.torque.generator.qname.QualifiedName;
-
+/**
+ * A test java outlet.
+ */
 public class JavaOutlet extends OutletImpl
 {
+    /** The class log. */
+    private static Log log = LogFactory.getLog(JavaOutlet.class);
+
+    /** A generator configuration option. */
+    private String foo;
+
+    /** Another generator configuration option. */
+    private String bar;
+
+    public JavaOutlet(QualifiedName name)
+    {
+        super(name);
+    }
+
+    @Override
+    public OutletResult execute(ControllerState controllerState)
+            throws GeneratorException
+    {
+        return new OutletResult(
+                "Test Outlet output; foo=" + foo + "; bar=" + bar);
+    }
+
+    public void setFoo(String foo)
+    {
+        log.info("foo set to " + foo);
+        this.foo = foo;
+    }
+
+    public void setBar(String bar)
+    {
+        log.info("bar set to " + bar);
+        this.bar = bar;
+    }
+
+    public String getBar()
+    {
+        return bar;
+    }
+
+    public String getFoo()
+    {
+        return foo;
+    }
+
     @Override
     public int hashCode()
     {
@@ -97,44 +144,4 @@ public class JavaOutlet extends OutletIm
         }
         return true;
     }
-
-    private static Log log = LogFactory.getLog(JavaOutlet.class);
-
-    private String foo;
-
-    private String bar;
-
-    public JavaOutlet(QualifiedName name)
-    {
-        super(name);
-    }
-
-    @Override
-    public String execute(ControllerState controllerState)
-            throws GeneratorException
-    {
-        return "Test Outlet output; foo=" + foo + "; bar=" + bar;
-    }
-
-    public void setFoo(String foo)
-    {
-        log.info("foo set to " + foo);
-        this.foo = foo;
-    }
-
-    public void setBar(String bar)
-    {
-        log.info("bar set to " + bar);
-        this.bar = bar;
-    }
-
-    public String getBar()
-    {
-        return bar;
-    }
-
-    public String getFoo()
-    {
-        return foo;
-    }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/JavadocOutletTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/JavadocOutletTest.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/JavadocOutletTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/JavadocOutletTest.java
Thu Aug  2 11:46:37 2012
@@ -20,6 +20,7 @@ package org.apache.torque.generator.outl
  */
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -28,6 +29,7 @@ import org.apache.torque.generator.confi
 import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.control.action.MergepointAction;
 import org.apache.torque.generator.control.action.OutputAction;
+import org.apache.torque.generator.outlet.OutletResult;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.junit.Before;
 import org.junit.Test;
@@ -64,7 +66,8 @@ public class JavadocOutletTest
                 new MergepointMapping(
                         "attributes",
                         mergepointActions));
-        String result = javadocOutlet.execute(new ControllerState());
+        OutletResult result = javadocOutlet.execute(new ControllerState());
+        assertTrue(result.isStringResult());
         assertEquals(
                     "    /**\n"
                   + "     * Test-body\n"
@@ -75,7 +78,7 @@ public class JavadocOutletTest
                   + "     *        of\n"
                   + "     *        param1\n"
                   + "     */\n",
-              result);
+              result.getStringResult());
     }
 
     /**

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutletTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutletTest.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutletTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutletTest.java
Thu Aug  2 11:46:37 2012
@@ -25,15 +25,20 @@ import java.io.File;
 
 import org.apache.torque.generator.GeneratorException;
 import org.apache.torque.generator.control.ControllerState;
-import org.apache.torque.generator.outlet.java.ModifySourcenameOutlet;
+import org.apache.torque.generator.outlet.OutletResult;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.junit.Before;
 import org.junit.Test;
 
+/**
+ * Component Tests for the ModifySourcenameOutlet.
+ */
 public class ModifySourcenameOutletTest
 {
+    /** System under test. */
     private ModifySourcenameOutlet outlet;
 
+    /** A mock controller state. */
     private ControllerState controllerState;
 
     @Before
@@ -49,8 +54,10 @@ public class ModifySourcenameOutletTest
     @Test
     public void testDefault() throws GeneratorException
     {
-        String result = outlet.execute(controllerState);
-        assertEquals("some-test-file-name.someTestExtension", result);
+        OutletResult result = outlet.execute(controllerState);
+        assertEquals(
+                "some-test-file-name.someTestExtension",
+                result.getStringResult());
     }
 
     @Test
@@ -60,24 +67,26 @@ public class ModifySourcenameOutletTest
         outlet.setDiscardTo("me-");
         outlet.setPrefix("prefix-");
         outlet.setSuffix("-suffix");
-        String result = outlet.execute(controllerState);
-        assertEquals("prefix-test-file-name.someTest-suffix", result);
+        OutletResult result = outlet.execute(controllerState);
+        assertEquals(
+                "prefix-test-file-name.someTest-suffix",
+                result.getStringResult());
     }
 
     @Test
     public void testDiscardFrom() throws GeneratorException
     {
         outlet.setDiscardFrom("-");
-        String result = outlet.execute(controllerState);
-        assertEquals("some", result);
+        OutletResult result = outlet.execute(controllerState);
+        assertEquals("some", result.getStringResult());
     }
 
     @Test
     public void testDiscardTo() throws GeneratorException
     {
         outlet.setDiscardTo("-");
-        String result = outlet.execute(controllerState);
-        assertEquals("name.someTestExtension", result);
+        OutletResult result = outlet.execute(controllerState);
+        assertEquals("name.someTestExtension", result.getStringResult());
     }
 
     @Test
@@ -85,15 +94,15 @@ public class ModifySourcenameOutletTest
     {
         outlet.setDiscardFrom("-");
         outlet.setDiscardTo("-");
-        String result = outlet.execute(controllerState);
-        assertEquals("", result);
+        OutletResult result = outlet.execute(controllerState);
+        assertEquals("", result.getStringResult());
     }
 
     @Test
     public void testSourceFilenameNull() throws GeneratorException
     {
         controllerState.setSourceFile(null);
-        String result = outlet.execute(controllerState);
-        assertEquals("", result);
+        OutletResult result = outlet.execute(controllerState);
+        assertEquals("", result.getStringResult());
     }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/NewlineOutletTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/NewlineOutletTest.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/NewlineOutletTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/NewlineOutletTest.java
Thu Aug  2 11:46:37 2012
@@ -22,12 +22,17 @@ package org.apache.torque.generator.outl
 import static org.junit.Assert.assertEquals;
 
 import org.apache.torque.generator.GeneratorException;
+import org.apache.torque.generator.outlet.OutletResult;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.junit.Before;
 import org.junit.Test;
 
+/**
+ * Component tests for the NewlineOutlet.
+ */
 public class NewlineOutletTest
 {
+    /** System under test. */
     private NewlineOutlet newlineOutlet;
 
     @Before
@@ -40,39 +45,39 @@ public class NewlineOutletTest
     @Test
     public void testDefault() throws GeneratorException
     {
-        String result = newlineOutlet.execute(null);
-        assertEquals("\n", result);
+        OutletResult result = newlineOutlet.execute(null);
+        assertEquals("\n", result.getStringResult());
     }
 
     @Test
     public void testWindowsStyle() throws GeneratorException
     {
         newlineOutlet.setWindowsStyle(true);
-        String result = newlineOutlet.execute(null);
-        assertEquals("\r\n", result);
+        OutletResult result = newlineOutlet.execute(null);
+        assertEquals("\r\n", result.getStringResult());
     }
 
     @Test()
     public void testCountZero() throws GeneratorException
     {
         newlineOutlet.setCount(0);
-        String result = newlineOutlet.execute(null);
-        assertEquals("", result);
+        OutletResult result = newlineOutlet.execute(null);
+        assertEquals("", result.getStringResult());
     }
 
     @Test(expected = GeneratorException.class)
     public void testCountLessThanZero() throws GeneratorException
     {
         newlineOutlet.setCount(-1);
-        String result = newlineOutlet.execute(null);
-        assertEquals("\n", result);
+        OutletResult result = newlineOutlet.execute(null);
+        assertEquals("\n", result.getStringResult());
     }
 
     @Test()
     public void testCountFive() throws GeneratorException
     {
         newlineOutlet.setCount(5);
-        String result = newlineOutlet.execute(null);
-        assertEquals("\n\n\n\n\n", result);
+        OutletResult result = newlineOutlet.execute(null);
+        assertEquals("\n\n\n\n\n", result.getStringResult());
     }
 }

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=1368426&r1=1368425&r2=1368426&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
Thu Aug  2 11:46:37 2012
@@ -22,10 +22,14 @@ package org.apache.torque.generator.outl
 import static org.junit.Assert.assertEquals;
 
 import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.apache.torque.generator.source.SourceElement;
 import org.junit.Test;
 
+/**
+ * Component tests for the XmlOutlet.
+ */
 public class XmlOutletTest
 {
     /**
@@ -41,10 +45,10 @@ public class XmlOutletTest
         ControllerState controllerState = new ControllerState();
         controllerState.setRootElement(rootElement);
         XmlOutlet xmlOutlet = new XmlOutlet(new QualifiedName("test"));
-        String result = xmlOutlet.execute(controllerState);
+        OutletResult result = xmlOutlet.execute(controllerState);
         assertEquals(
                 "<root>\n  <child/>\n</root>\n",
-                result);
+                result.getStringResult());
     }
 
     /**
@@ -61,9 +65,9 @@ public class XmlOutletTest
         controllerState.setRootElement(rootElement);
         XmlOutlet xmlOutlet = new XmlOutlet(new QualifiedName("test"));
         xmlOutlet.setCreateIdAttributes(true);
-        String result = xmlOutlet.execute(controllerState);
+        OutletResult result = xmlOutlet.execute(controllerState);
         assertEquals(
                 "<root id=\"1\">\n  <child id=\"2\"/>\n</root>\n",
-                result);
+                result.getStringResult());
     }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/template/groovy/GroovyOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/template/groovy/GroovyOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/template/groovy/GroovyOutlet.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/template/groovy/GroovyOutlet.java
Thu Aug  2 11:46:37 2012
@@ -28,6 +28,7 @@ import org.apache.torque.generator.Gener
 import org.apache.torque.generator.configuration.ConfigurationException;
 import org.apache.torque.generator.configuration.ConfigurationProvider;
 import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.apache.torque.generator.template.TemplateOutletImpl;
 
@@ -81,7 +82,7 @@ public class GroovyOutlet extends Templa
      * @see org.apache.torque.generator.outlet.Outlet#execute(ControllerState)
      */
     @Override
-    public String execute(ControllerState controllerState)
+    public OutletResult execute(ControllerState controllerState)
         throws GeneratorException
 
     {
@@ -97,7 +98,7 @@ public class GroovyOutlet extends Templa
 
             String result = (String) shell.evaluate(
                     getContent(controllerState));
-            return result;
+            return new OutletResult(result);
         }
         finally
         {

Modified: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
Thu Aug  2 11:46:37 2012
@@ -60,5 +60,11 @@
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy"/>
   </output>
+  <output name="torqueImage" file="logo.png">
+    <source xsi:type="fileSource" elements="properties">
+      <include>propertiesData.properties</include>
+    </source>
+    <outlet name="org.apache.torque.generator.logoCopy"/>
+  </output>
 </control>
   
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/outlets/logoCopyOutlet.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/outlets/logoCopyOutlet.xml?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/outlets/logoCopyOutlet.xml
(added)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/outlets/logoCopyOutlet.xml
Thu Aug  2 11:46:37 2012
@@ -0,0 +1,28 @@
+<?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.
+-->
+
+<outlets xmlns="http://db.apache.org/torque/4.0/generator/configuration"
+    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="org.apache.torque.generator.logoCopy"
+      xsi:type="copyOutlet" 
+      path="torque-logo-new.png">
+  </outlet>
+</outlets>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/resources/torque-logo-new.png
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/resources/torque-logo-new.png?rev=1368426&view=auto
==============================================================================
Binary file - no diff available.

Propchange: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/resources/torque-logo-new.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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