-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1452 Prepare for new ConfigurationReader and Adapt Templates process (#…
…1499) * #1452 changed dynamic groupId in master-pom.xml to fixed separated all templates sets into deployables moved util tests into templates-devon4j-utils plug-in renamed devon4j-templates to devon4j-templates-tests * Update crud-java-server-app-complex/pom.xml delete relative Path * #1452 reformatted pom.xml codes * #1452 added test resources for new TemplateSetTest * #1452 split ContextConfigurationReader into AbstractConfigurationReader and ContextConfigurationSetReader added new ContextConfigurationAnalyzer implemented rough template type detection * #1452 adapted core extract templates process and find templates methods to new template sets configuration ensured backwards compatibility in ConfigurationFinder and ExtractTemplatesUtil fixed some typos in ConfigurationFinder refactored CobiGenPaths class added getTemplateSetsFolderPath and createFolder methods to CobiGenPaths added new constants for downloaded, adapted and template-sets to ConfigurationConstants added processJars method to ExtractTemplatesUtil set processJar and getJarFile methods deprecated adjusted info messages in ExtractTemplatesUtil added first TemplateProcessingTest class + resources adjusted CobiGenFactory extractTemplate method * #1452 fixed resolve of doubled CobiGen_Templates directory * #1452 fixed ConfigurationUtilTest * #1452 implemented requested changes combined 3rd and 4th check into one in ConfigurationFinder fixed old templates folder detection in ExtractTemplatesUtil adjusted javadoc of processJars method in ExtractTemplatesUtil adjusted return of getTemplateSetsFolderPath * #1452 renamed variable name as requested Co-authored-by: LarsReinken <[email protected]>
- Loading branch information
1 parent
6f5e2ce
commit e258c4b
Showing
22 changed files
with
726 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...-core-systemtest/src/test/java/com/devonfw/cobigen/systemtest/TemplateProcessingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package com.devonfw.cobigen.systemtest; | ||
|
||
import static com.github.stefanbirkner.systemlambda.SystemLambda.withEnvironmentVariable; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import com.devonfw.cobigen.api.constants.ConfigurationConstants; | ||
import com.devonfw.cobigen.impl.CobiGenFactory; | ||
import com.devonfw.cobigen.impl.util.ConfigurationFinder; | ||
import com.devonfw.cobigen.systemtest.common.AbstractApiTest; | ||
|
||
/** | ||
* Test suite for extract templates scenarios. | ||
*/ | ||
public class TemplateProcessingTest extends AbstractApiTest { | ||
|
||
/** | ||
* Root path to all resources used in this test case | ||
*/ | ||
private static String testFileRootPath = apiTestsRootPath + "TemplateProcessingTest/"; | ||
|
||
/** Temporary files rule to create temporary folders or files */ | ||
@Rule | ||
public TemporaryFolder tempFolder = new TemporaryFolder(); | ||
|
||
/** | ||
* temporary project to store CobiGen home | ||
*/ | ||
File cobiGenHome; | ||
|
||
/** | ||
* Creates a temporary CobiGen home directory for each test | ||
* | ||
* @throws IOException if an Exception occurs | ||
*/ | ||
@Before | ||
public void prepare() throws IOException { | ||
|
||
this.cobiGenHome = this.tempFolder.newFolder("playground", "templatesHome"); | ||
} | ||
|
||
/** | ||
* @throws IOException if an Exception occurs | ||
*/ | ||
public void extractTemplateSetsTest() throws IOException { | ||
|
||
FileUtils.copyDirectory(new File(testFileRootPath + "templates"), | ||
this.cobiGenHome.toPath().resolve("template-sets/downloaded").toFile()); | ||
CobiGenFactory.extractTemplates(); | ||
Path adaptedFolder = this.cobiGenHome.toPath().resolve(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_PATH) | ||
.resolve(ConfigurationConstants.ADAPTED_FOLDER); | ||
Path extractedJar1 = adaptedFolder.resolve("template-test1-0.0.1"); | ||
Path extractedJar2 = adaptedFolder.resolve("template-test2-0.0.1"); | ||
assertThat(Files.exists(extractedJar1)); | ||
assertThat(Files.exists(extractedJar2)); | ||
} | ||
|
||
/** | ||
* @throws IOException if an Exception occurs | ||
*/ | ||
public void extractTemplatesWithOldConfiguration() throws IOException { | ||
|
||
Path cobigenTemplatesProject = this.cobiGenHome.toPath() | ||
.resolve(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATES_PATH) | ||
.resolve(ConfigurationConstants.COBIGEN_TEMPLATES); | ||
Files.createDirectories(cobigenTemplatesProject); | ||
CobiGenFactory.extractTemplates(); | ||
assertThat(Files.exists(cobigenTemplatesProject)); | ||
} | ||
|
||
/** | ||
* Test of extract templates with old CobiGen_Templates project existing with custom COBIGEN_HOME environment variable | ||
* | ||
* @throws Exception test fails | ||
*/ | ||
@Test | ||
public void testExtractTemplatesWithOldConfiguration() throws Exception { | ||
|
||
withEnvironmentVariable("COBIGEN_HOME", this.cobiGenHome.toPath().toString()) | ||
.execute(() -> extractTemplatesWithOldConfiguration()); | ||
} | ||
|
||
/** | ||
* Test of extract template sets with custom COBIGEN_HOME environment variable | ||
* | ||
* @throws Exception test fails | ||
*/ | ||
@Test | ||
public void testExtractTemplateSets() throws Exception { | ||
|
||
withEnvironmentVariable("COBIGEN_HOME", this.cobiGenHome.toPath().toString()) | ||
.execute(() -> extractTemplateSetsTest()); | ||
} | ||
|
||
/** | ||
* @throws IOException if an Exception occurs | ||
*/ | ||
public void findTemplateSetJarsWithBackwardsCompatibilityTest() throws IOException { | ||
|
||
FileUtils.createParentDirectories(new File(testFileRootPath + "template-sets")); | ||
URI templatesLocationURI = ConfigurationFinder.findTemplatesLocation(); | ||
assertThat(templatesLocationURI.compareTo(this.cobiGenHome.toPath().resolve("template-sets").toUri())); | ||
|
||
} | ||
|
||
/** | ||
* Test of find template set downloaded folder to ensure backwards compatibility with custom COBIGEN_HOME environment | ||
* variable | ||
* | ||
* @throws Exception test fails | ||
*/ | ||
@Test | ||
public void testfindTemplateSetDownloadedWithBackwardsCompatibility() throws Exception { | ||
|
||
withEnvironmentVariable("COBIGEN_HOME", this.cobiGenHome.toPath().toString()) | ||
.execute(() -> findTemplateSetJarsWithBackwardsCompatibilityTest()); | ||
} | ||
|
||
} |
Binary file added
BIN
+2.96 KB
...t/resources/testdata/systemtest/TemplateProcessingTest/templates/template-test1-0.0.1.jar
Binary file not shown.
Binary file added
BIN
+2.96 KB
...t/resources/testdata/systemtest/TemplateProcessingTest/templates/template-test2-0.0.1.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
...sources/testdata/systemtest/TemplateSetTest/template-test0/src/main/templates/context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<contextConfiguration xmlns="http://capgemini.com/devonfw/cobigen/ContextConfiguration" version="2.1"> | ||
<trigger id="entities" type="mockplugin"> | ||
<matcher type="fqn" value=".+"> | ||
</matcher> | ||
</trigger> | ||
</contextConfiguration> |
1 change: 1 addition & 0 deletions
1
...s/testdata/systemtest/TemplateSetTest/template-test0/src/main/templates/generated.txt.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
overwritten |
11 changes: 11 additions & 0 deletions
11
...urces/testdata/systemtest/TemplateSetTest/template-test0/src/main/templates/templates.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<templatesConfiguration xmlns="http://capgemini.com/devonfw/cobigen/TemplatesConfiguration" version="2.1"> | ||
<templates> | ||
<template name="t1" destinationPath="generated.txt" templateFile="generated.txt.ftl" mergeStrategy="override"/> | ||
</templates> | ||
<increments> | ||
<increment name="i1" description="the only increment"> | ||
<templateRef ref="t1"/> | ||
</increment> | ||
</increments> | ||
</templatesConfiguration> |
Binary file added
BIN
+2.96 KB
...ystemtest/src/test/resources/testdata/systemtest/TemplateSetTest/template-test1-0.0.1.jar
Binary file not shown.
Binary file added
BIN
+2.96 KB
...ystemtest/src/test/resources/testdata/systemtest/TemplateSetTest/template-test2-0.0.1.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.