Skip to content

Commit

Permalink
minor: removed obsolete thymleaf code
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and romani committed Jun 24, 2018
1 parent 508d92d commit 42cf0fa
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 156 deletions.
1 change: 0 additions & 1 deletion releasenotes-builder/config/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<allow pkg="org.apache.commons.lang"/>
<allow pkg="org.eclipse.jgit"/>
<allow pkg="org.kohsuke.github"/>
<allow pkg="org.thymeleaf"/>
<allow pkg="com.github.checkstyle"/>
<allow pkg="com.google.common"/>
<allow pkg="freemarker.template"/>
Expand Down
6 changes: 0 additions & 6 deletions releasenotes-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<maven.plugin.jgit.version>4.1.0.201509280440-r</maven.plugin.jgit.version>
<maven.plugin.slf4j.version>1.7.12</maven.plugin.slf4j.version>
<maven.plugin.freemarker.version>2.3.22</maven.plugin.freemarker.version>
<maven.plugin.thymeleaf.version>3.0.0.BETA01</maven.plugin.thymeleaf.version>
<maven.plugin.apache.commons.cli.version>1.3.1</maven.plugin.apache.commons.cli.version>
<maven.plugin.apache.commons.lang.version>2.6</maven.plugin.apache.commons.lang.version>
<maven.plugin.twitter4j.version>4.0.4</maven.plugin.twitter4j.version>
Expand Down Expand Up @@ -54,11 +53,6 @@
<artifactId>freemarker</artifactId>
<version>${maven.plugin.freemarker.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring3</artifactId>
<version>${maven.plugin.thymeleaf.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,14 @@
import java.util.Locale;
import java.util.Map;

import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import org.thymeleaf.context.IContext;
import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

import com.google.common.collect.Multimap;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;

/**
* Util class to generate release notes output file with FreeMarker or Thymeleaf template engines.
* Util class to generate release notes output file with FreeMarker template engines.
* @author Andrei Selkin
*/
public final class TemplateProcessor {
Expand All @@ -53,29 +47,6 @@ public final class TemplateProcessor {
/** Default constructor. */
private TemplateProcessor() { }

/**
* Generates output file with release notes using Thymeleaf.
* @param variables the map which represents template variables.
* @param outputFile output file.
* @param templateFilename template name.
* @throws IOException if I/O error occurs.
*/
public static void generateWithThymeleaf(Map<String, Object> variables, String outputFile,
String templateFilename) throws IOException {

final TemplateEngine engine = new TemplateEngine();
final AbstractConfigurableTemplateResolver resolver = new ClassLoaderTemplateResolver();
resolver.setPrefix(TEMPLATE_FOLDER_PATH);
engine.setTemplateResolver(resolver);

final IContext ctx = new Context(Locale.US, variables);

try (Writer fileWriter = new OutputStreamWriter(
new FileOutputStream(outputFile), StandardCharsets.UTF_8)) {
engine.process(templateFilename, ctx, fileWriter);
}
}

/**
* Generates output file with release notes using FreeMarker.
* @param variables the map which represents template variables.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class TemplateProcessorTest {

private static TemporaryFolder tmpDir;

private static final String THYMELEAF_XDOC_TEMPLATE_FILE = "xdoc_thymeleaf.template";
private static final String FREEMARKER_XDOC_TEMPLATE_FILE = "xdoc_freemarker.template";

@BeforeClass
Expand All @@ -51,90 +50,6 @@ public static void setup() throws IOException {
tmpDir.create();
}

@Test
public void testGenerateWithThymeleafOnlyBreakingCompatibilitySection() throws Exception {
final Map<String, Object> templateVariables = new HashMap<>();
templateVariables.put("releaseNo", "1.0.0");
templateVariables.put("breakingMessages", getMockReleasenotesMessages());

final File actualNotes = tmpDir.newFile("xdoc1.txt");
TemplateProcessor.generateWithThymeleaf(templateVariables, actualNotes.getAbsolutePath(),
THYMELEAF_XDOC_TEMPLATE_FILE);

final String expectedXdoc =
getFileContents(getPath("correct_breaking_compatibility_section.txt").toFile());
final String actualXdoc = getFileContents(actualNotes);

assertEquals(expectedXdoc, actualXdoc);
}

@Test
public void testGenerateWithThymeleafOnlyNewSection() throws Exception {
final Map<String, Object> templateVariables = new HashMap<>();
templateVariables.put("releaseNo", "1.0.0");
templateVariables.put("newMessages", getMockReleasenotesMessages());

final File actualNotes = tmpDir.newFile("xdoc2.txt");
TemplateProcessor.generateWithThymeleaf(templateVariables, actualNotes.getAbsolutePath(),
THYMELEAF_XDOC_TEMPLATE_FILE);

final String expectedXdoc = getFileContents(getPath("correct_new_section.txt").toFile());
final String actualXdoc = getFileContents(actualNotes);

assertEquals(expectedXdoc, actualXdoc);
}

@Test
public void testGenerateWithThymeleafOnlyBugSection() throws Exception {
final Map<String, Object> templateVariables = new HashMap<>();
templateVariables.put("releaseNo", "1.0.0");
templateVariables.put("bugMessages", getMockReleasenotesMessages());

final File actualNotes = tmpDir.newFile("xdoc3.txt");
TemplateProcessor.generateWithThymeleaf(templateVariables, actualNotes.getAbsolutePath(),
THYMELEAF_XDOC_TEMPLATE_FILE);

final String expectedXdoc = getFileContents(getPath("correct_bug_section.txt").toFile());
final String actualXdoc = getFileContents(actualNotes);

assertEquals(expectedXdoc, actualXdoc);
}

@Test
public void testGenerateWithThymeleafOnlyNotesSection() throws Exception {
final Map<String, Object> templateVariables = new HashMap<>();
templateVariables.put("releaseNo", "1.0.0");
templateVariables.put("notesMessages", getMockReleasenotesMessages());

final File actualNotes = tmpDir.newFile("xdoc4.txt");
TemplateProcessor.generateWithThymeleaf(templateVariables, actualNotes.getAbsolutePath(),
THYMELEAF_XDOC_TEMPLATE_FILE);

final String expectedXdoc = getFileContents(getPath("correct_notes_section.txt").toFile());
final String actualXdoc = getFileContents(actualNotes);

assertEquals(expectedXdoc, actualXdoc);
}

@Test
public void testGenerateWithThymeleafAllSections() throws Exception {
final Map<String, Object> templateVariables = new HashMap<>();
templateVariables.put("releaseNo", "1.0.0");
templateVariables.put("breakingMessages", getMockReleasenotesMessages());
templateVariables.put("newMessages", getMockReleasenotesMessages());
templateVariables.put("bugMessages", getMockReleasenotesMessages());
templateVariables.put("notesMessages", getMockReleasenotesMessages());

final File actualNotes = tmpDir.newFile("xdoc5.txt");
TemplateProcessor.generateWithThymeleaf(templateVariables, actualNotes.getAbsolutePath(),
THYMELEAF_XDOC_TEMPLATE_FILE);

final String expectedXdoc = getFileContents(getPath("correct_all_sections.txt").toFile());
final String actualXdoc = getFileContents(actualNotes);

assertEquals(expectedXdoc, actualXdoc);
}

@Test
public void testGenerateWithFreemarkerOnlyBreakingCompatibilitySection() throws Exception {
final Map<String, Object> templateVariables = new HashMap<>();
Expand Down

0 comments on commit 42cf0fa

Please sign in to comment.