This is an automated email from the ASF dual-hosted git repository. sgoeschl pushed a commit to branch FREEMARKER-148 in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git
commit 8f498f52a8c47a6ef3bb4dc6e73aecf046fa5a7d Author: Siegfried Goeschl <[email protected]> AuthorDate: Sun Jul 5 10:34:43 2020 +0200 FREEMARKER-148 Make usage of "DataSources" more "Freemarker" like --- freemarker-generator-cli/CHANGELOG.md | 2 ++ .../freemarker/generator/cli/ExamplesTest.java | 24 ++++++++++++++++++++++ freemarker-generator-maven-plugin/pom.xml | 1 + .../commonscsv/impl/CommonsCSVPrinterFacade.java | 16 +++++++++++++++ pom.xml | 18 ++++++++++++++-- 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/freemarker-generator-cli/CHANGELOG.md b/freemarker-generator-cli/CHANGELOG.md index 70d43a1..6b03fc4 100644 --- a/freemarker-generator-cli/CHANGELOG.md +++ b/freemarker-generator-cli/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. We try to a ## 0.1.0-SNAPSHOT ### Added +* [FREEMARKER-148] Make usage of "DataSources" more "Freemarker" like * [FREEMARKER-149] Support multiple template transformations on the command line * [FREEMARKER-144] Proof Of Concept for providing DataFrames * [FREEMARKER-142] Support Transformation Of Directories @@ -41,4 +42,5 @@ All notable changes to this project will be documented in this file. We try to a [FREEMARKER-144]: https://issues.apache.org/jira/browse/FREEMARKER-144 [FREEMARKER-146]: https://issues.apache.org/jira/browse/FREEMARKER-146 [FREEMARKER-147]: https://issues.apache.org/jira/browse/FREEMARKER-147 +[FREEMARKER-148]: https://issues.apache.org/jira/browse/FREEMARKER-148 [FREEMARKER-149]: https://issues.apache.org/jira/browse/FREEMARKER-149 \ No newline at end of file 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 e66d457..308d0df 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 @@ -21,6 +21,7 @@ import org.junit.Test; import java.io.IOException; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -139,6 +140,29 @@ public class ExamplesTest extends AbstractMainTest { } @Test + public void shouldSupportDataSourcesAccessInFTL() throws IOException { + final String args = "examples/data/json/github-users.json examples/data/csv/contract.csv"; + + // check FreeMarker directives + assertEquals("true", execute(args + " -i ${DataSources?has_content?c}")); + assertEquals("2", execute(args + " -i ${DataSources?size}")); + + // check FTL array-style access + assertEquals("github-users.json", execute(args + " -i ${DataSources[0].name}")); + assertEquals("github-users.json", execute(args + " -i ${DataSources.get(0).name}")); + + // check FTL map-style access + assertEquals("github-users.json", execute(args + " -i ${DataSources[\"github-users.json\"].name}")); + assertEquals("github-users.json", execute(args + " -i ${DataSources.get(\"github-users.json\").name}")); + + // check arbitrary methods + assertEquals("false", execute(args + " -i ${DataSources.empty?c}")); + assertEquals("false", execute(args + " -i ${DataSources.isEmpty()?c}")); + assertEquals("2", execute(args + " -i ${DataSources.size()}")); + assertEquals("worx", execute(args + " -i ${DataSources.close()}worx")); + } + + @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-maven-plugin/pom.xml b/freemarker-generator-maven-plugin/pom.xml index be360ec..30442ec 100644 --- a/freemarker-generator-maven-plugin/pom.xml +++ b/freemarker-generator-maven-plugin/pom.xml @@ -167,6 +167,7 @@ <artifactId>apache-rat-plugin</artifactId> <configuration> <excludes> + <exclude>CHANGELOG.md</exclude> <exclude>README.md</exclude> <exclude>src/site/markdown/**/*.md</exclude> <excludde>**/*.json</excludde> diff --git a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/commonscsv/impl/CommonsCSVPrinterFacade.java b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/commonscsv/impl/CommonsCSVPrinterFacade.java index c8e8ac5..9909d17 100644 --- a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/commonscsv/impl/CommonsCSVPrinterFacade.java +++ b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/commonscsv/impl/CommonsCSVPrinterFacade.java @@ -1,3 +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. + */ package org.apache.freemarker.generator.tools.commonscsv.impl; import org.apache.commons.csv.CSVFormat; diff --git a/pom.xml b/pom.xml index 05fa956..4e132e8 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,9 @@ <organization>ASF</organization> <organizationUrl>https://www.apache.org</organizationUrl> </developer> + <developer> + <name>Benjamin Jackson</name> + </developer> </developers> <dependencyManagement> @@ -149,7 +152,7 @@ </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> - <version>3.2.0</version> + <version>3.2.0</version> </plugin> <plugin> <artifactId>maven-clean-plugin</artifactId> @@ -169,7 +172,7 @@ </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.1.1</version> + <version>3.2.0</version> </plugin> <plugin> <artifactId>maven-jxr-plugin</artifactId> @@ -273,6 +276,17 @@ <linkXRef>false</linkXRef> </configuration> </plugin> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <reportSets> + <reportSet> + <id>default</id> + <reports> + <report>javadoc</report> + </reports> + </reportSet> + </reportSets> + </plugin> </plugins> </reporting> </project> \ No newline at end of file
