This is an automated email from the ASF dual-hosted git repository.
sgoeschl pushed a commit to branch FREEMARKER-188
in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git
The following commit(s) were added to refs/heads/FREEMARKER-188 by this push:
new daf5858 FREEMARKER-188 Improve tests
daf5858 is described below
commit daf5858463028f4370c9e17c5e561404c5f1f66d
Author: Siegfried Goeschl <[email protected]>
AuthorDate: Mon Sep 27 21:30:16 2021 +0200
FREEMARKER-188 Improve tests
---
freemarker-generator-cli/src/app/scripts/run-examples.bat | 10 ++++++++++
freemarker-generator-cli/src/app/scripts/run-examples.sh | 10 ++++++++++
.../org/apache/freemarker/generator/cli/ExamplesTest.java | 14 ++++++++++++++
.../generator/tools/commonsexec/CommonsExecToolTest.java | 14 +++++++++-----
4 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/freemarker-generator-cli/src/app/scripts/run-examples.bat
b/freemarker-generator-cli/src/app/scripts/run-examples.bat
index 6512dca..7adcb91 100644
--- a/freemarker-generator-cli/src/app/scripts/run-examples.bat
+++ b/freemarker-generator-cli/src/app/scripts/run-examples.bat
@@ -189,5 +189,15 @@ echo "examples\templates\yaml\txt\transform.ftl"
echo "templates\freemarker-generator\yaml\json\transform.ftl"
%FREEMARKER_CMD% -t freemarker-generator\yaml\json\transform.ftl
examples\data\yaml\swagger-spec.yaml > target\out\swagger-spec.json
+REM =========================================================================
+REM DataSource Seeding
+REM =========================================================================
+
+echo "examples\data\csv"
+%FREEMARKER_CMD% --seed=datasource --template
freemarker-generator\csv\html\transform.ftl --output target\out\datasource\csv
--output-mapper="*.html" examples\data\csv
+
+echo "examples\data\csv"
+%FREEMARKER_CMD% --seed=datasource --template
freemarker-generator\csv\html\transform.ftl --data-source .
--data-source-include="*.csv" --output target\out\datasource\csv
--output-mapper="*.html"
+
echo "Created the following sample files in .\target\out"
dir .\target\out
diff --git a/freemarker-generator-cli/src/app/scripts/run-examples.sh
b/freemarker-generator-cli/src/app/scripts/run-examples.sh
index 09d09af..5298eaf 100755
--- a/freemarker-generator-cli/src/app/scripts/run-examples.sh
+++ b/freemarker-generator-cli/src/app/scripts/run-examples.sh
@@ -210,5 +210,15 @@ $FREEMARKER_CMD -t
examples/templates/yaml/txt/transform.ftl examples/data/yaml/
echo "templates/freemarker-generator/yaml/json/transform.ftl"
$FREEMARKER_CMD -t freemarker-generator/yaml/json/transform.ftl
examples/data/yaml/swagger-spec.yaml > target/out/swagger-spec.json || { echo
>&2 "Test failed. Aborting."; exit 1; }
+#############################################################################
+# DataSource Seeding
+#############################################################################
+
+echo "examples/data/csv"
+$FREEMARKER_CMD --seed=datasource --template
freemarker-generator/csv/html/transform.ftl --output target/out/datasource/csv
--output-mapper="*.html" examples/data/csv
+
+echo "examples/data/csv"
+$FREEMARKER_CMD --seed=datasource --template
freemarker-generator/csv/html/transform.ftl --data-source .
--data-source-include="*.csv" --output target/out/datasource/csv
--output-mapper="*.html"
+
echo "Created the following sample files in ./target/out"
ls -l ./target/out
diff --git
a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
index 49e536f..a5192e4 100644
---
a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
+++
b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
@@ -178,6 +178,20 @@ public class ExamplesTest extends AbstractMainTest {
}
@Test
+ public void shouldSupportDataSourceSeedingTransformation() throws
IOException {
+ final String output = execute("--seed=datasource " +
+ "--template freemarker-generator/csv/html/transform.ftl " +
+ "--data-source src/app/examples/data/csv " +
+ "--data-source-include=*.csv " +
+ "--output target " +
+ "--output-mapper=*.html");
+
+ assertTrue(output.startsWith("<!DOCTYPE html>"));
+ assertTrue(output.contains("The Electric Company"));
+ assertTrue(output.contains("test user DDDDDDD"));
+ }
+
+ @Test
@Ignore("Manual test to check memory consumption and resource handling")
public void shouldCloseAllResources() throws IOException {
for (int i = 0; i < 500; i++) {
diff --git
a/freemarker-generator-tools/src/test/java/org/apache/freemarker/generator/tools/commonsexec/CommonsExecToolTest.java
b/freemarker-generator-tools/src/test/java/org/apache/freemarker/generator/tools/commonsexec/CommonsExecToolTest.java
index 495b8a4..a9a49d2 100644
---
a/freemarker-generator-tools/src/test/java/org/apache/freemarker/generator/tools/commonsexec/CommonsExecToolTest.java
+++
b/freemarker-generator-tools/src/test/java/org/apache/freemarker/generator/tools/commonsexec/CommonsExecToolTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.freemarker.generator.tools.commonsexec;
+import org.apache.freemarker.generator.base.util.OperatingSystem;
import org.junit.Test;
import java.util.Collections;
@@ -27,16 +28,19 @@ public class CommonsExecToolTest {
@Test
public void shouldExecuteCommandLine() {
- final String output = commonsExecTool().execute("echo Hello World!");
-
- assertEquals("Hello World!\n", output);
+ if (OperatingSystem.isMac() || OperatingSystem.isUnix()) {
+ final String output = commonsExecTool().execute("echo Hello
World!");
+ assertEquals("Hello World!\n", output);
+ }
}
@Test
public void shouldExecuteCommandLineArgs() {
- final String output = commonsExecTool().execute("echo",
Collections.singletonList("Hello World!"));
+ if (OperatingSystem.isMac() || OperatingSystem.isUnix()) {
+ final String output = commonsExecTool().execute("echo",
Collections.singletonList("Hello World!"));
- assertEquals("\"Hello World!\"\n", output);
+ assertEquals("\"Hello World!\"\n", output);
+ }
}
@Test(expected = RuntimeException.class)