-
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.
1551 merge master into template_set_deployables (#1552)
* 1526 fixed infinite loop while generating from source code (#1547) * #1526 added new Eclipse text input test added a test which tests a simple generate from text input added a new processCobiGenWithTextInput method to EclipseCobiGenUtils refactored processCobiGen method added new generateWithSelectedIncrements method to EclipseCobiGenUtils * #1526 fixed infinite loop wrapped getActiveWorkbenchWindow into asynchronous runnables added workbenchWindow class variable added extra check for FileEditorInput * #1526 added missing files added .classpath and .project files * #1526 fixed Eclipse crash changed asynchronous runnable to synchronized * #1551 disabled GenerateFromTextInput test
- Loading branch information
1 parent
b5a2577
commit 7b6bf79
Showing
12 changed files
with
299 additions
and
15 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...clipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/GenerateFromTextInputTest.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,93 @@ | ||
package com.devonfw.cobigen.eclipse.test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.jdt.core.IJavaProject; | ||
import org.eclipse.jdt.ui.JavaUI; | ||
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; | ||
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; | ||
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; | ||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; | ||
import org.junit.BeforeClass; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants; | ||
import com.devonfw.cobigen.eclipse.test.common.SystemTest; | ||
import com.devonfw.cobigen.eclipse.test.common.swtbot.AllJobsAreFinished; | ||
import com.devonfw.cobigen.eclipse.test.common.utils.EclipseCobiGenUtils; | ||
import com.devonfw.cobigen.eclipse.test.common.utils.EclipseUtils; | ||
|
||
/** | ||
* Test suite for issues with generation from text selection | ||
*/ | ||
@RunWith(SWTBotJunit4ClassRunner.class) | ||
public class GenerateFromTextInputTest extends SystemTest { | ||
|
||
/** Root path of the Test Resources */ | ||
private static final String resourcesRootPath = "src/main/resources/GenerateFromTextInputTest/"; | ||
|
||
/** | ||
* Setup workbench appropriately for tests | ||
* | ||
* @throws Exception test fails | ||
*/ | ||
@BeforeClass | ||
public static void setupClass() throws Exception { | ||
|
||
EclipseUtils.cleanWorkspace(bot, true); | ||
// import the configuration project for this test | ||
EclipseUtils.importExistingGeneralProject(bot, new File(resourcesRootPath + "templates").getAbsolutePath()); | ||
EclipseUtils.updateMavenProject(bot, ResourceConstants.CONFIG_PROJECT_NAME); | ||
} | ||
|
||
/** | ||
* Tests if a generate from text selection works properly | ||
* | ||
* Reported in: https://github.com/devonfw/cobigen/issues/1526 | ||
* | ||
* @throws Exception Test fails | ||
*/ | ||
@Ignore | ||
@Test | ||
public void testGenerateFromTextDoesNotLoop() throws Exception { | ||
|
||
// create a new temporary java project and copy java class used as an input for CobiGen | ||
String testProjectName = "TestInputProj"; | ||
IJavaProject project = this.tmpMavenProjectRule.createProject(testProjectName); | ||
FileUtils.copyFile(new File(resourcesRootPath + "input/PlainInput.java"), | ||
project.getUnderlyingResource().getLocation().append("src/main/java/main/PlainInput.java").toFile()); | ||
project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); | ||
this.tmpMavenProjectRule.updateProject(); | ||
|
||
// expand the new file in the package explorer | ||
SWTBotView view = bot.viewById(JavaUI.ID_PACKAGES); | ||
SWTBotTreeItem javaClassItem = view.bot().tree().expandNode(testProjectName, "src/main/java", "main", | ||
"PlainInput.java"); | ||
|
||
// double click on the file to open the Java editor | ||
javaClassItem.select().doubleClick(); | ||
|
||
SWTBotEclipseEditor textEditor = bot.editorByTitle("PlainInput.java").toTextEditor(); | ||
|
||
// select 1st line of code as input | ||
textEditor.selectLine(0); | ||
|
||
EclipseCobiGenUtils.processCobiGenWithTextInput(bot, textEditor, "increment1"); | ||
EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); | ||
|
||
// check assertions | ||
bot.waitUntil(new AllJobsAreFinished(), 10000); | ||
IFile generationResult = project.getProject().getFile("TestOutput.txt"); | ||
assertThat(generationResult.exists()).isTrue(); | ||
|
||
} | ||
|
||
} |
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
5 changes: 5 additions & 0 deletions
5
...e/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/input/PlainInput.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,5 @@ | ||
package main; | ||
|
||
public class PlainInput { | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...se/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/.classpath
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
23 changes: 23 additions & 0 deletions
23
...ipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/.project
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>CobiGen_Templates</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
17 changes: 17 additions & 0 deletions
17
...e/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/logback.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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- This file is for logback classic. The file contains the configuration | ||
for sl4j logging --> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- defines the level of logging --> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n | ||
</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<root level="DEBUG"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
24 changes: 24 additions & 0 deletions
24
...lipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/pom.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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.devonfw.cobigen</groupId> | ||
<artifactId>templates-oasp</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
<name>CobiGen OASP Templates</name> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>javax.ws.rs-api</artifactId> | ||
<version>2.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
1 change: 1 addition & 0 deletions
1
...urces/GenerateFromTextInputTest/templates/src/main/templates/template1/TestOutput.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 @@ | ||
This is a test |
7 changes: 7 additions & 0 deletions
7
...in/resources/GenerateFromTextInputTest/templates/src/main/templates/template1/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.2"> | ||
<trigger id="test" type="java"> | ||
<matcher type="fqn" value=".*"> | ||
</matcher> | ||
</trigger> | ||
</contextConfiguration> |
11 changes: 11 additions & 0 deletions
11
.../resources/GenerateFromTextInputTest/templates/src/main/templates/template1/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="TestOutput.txt" templateFile="TestOutput.txt.ftl"/> | ||
</templates> | ||
<increments> | ||
<increment name="i1" description="increment1"> | ||
<templateRef ref="t1"/> | ||
</increment> | ||
</increments> | ||
</templatesConfiguration> |
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