Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import org.hibernate.tool.it.gradle.TestTemplate;

Expand All @@ -24,16 +23,13 @@ public class JpaDefaultTest extends TestTemplate {
private static final List<String> GRADLE_INIT_PROJECT_ARGUMENTS = List.of(
"init", "--type", "java-application", "--dsl", "groovy", "--test-framework", "junit-jupiter", "--java-version", "17");

@TempDir
private File projectDir;

private File gradlePropertiesFile;
private File gradleBuildFile;
private File databaseFile;

@Test
public void testTutorial() throws Exception {
assertTrue(projectDir.exists());
assertTrue(getProjectDir().exists());
createGradleProject();
editGradleBuildFile();
editGradlePropertiesFile();
Expand All @@ -56,19 +52,19 @@ private void createGradleProject() throws Exception {
GradleRunner runner = GradleRunner.create();
runner.withArguments(GRADLE_INIT_PROJECT_ARGUMENTS);
runner.forwardOutput();
runner.withProjectDir(projectDir);
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(projectDir, "gradle.properties");
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
File appDir = new File(projectDir, "app");
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
gradleBuildFile = new File(appDir, "build.gradle");
assertTrue(gradleBuildFile.exists());
assertTrue(gradleBuildFile.isFile());
databaseFile = new File(projectDir, "database/test.mv.db");
databaseFile = new File(getProjectDir(), "database/test.mv.db");
assertFalse(databaseFile.exists());
}

Expand Down Expand Up @@ -104,7 +100,7 @@ private void createDatabase() throws Exception {
}

private void createHibernatePropertiesFile() throws Exception {
File hibernatePropertiesFile = new File(projectDir, "app/src/main/resources/hibernate.properties");
File hibernatePropertiesFile = new File(getProjectDir(), "app/src/main/resources/hibernate.properties");
StringBuffer hibernatePropertiesFileContents = new StringBuffer();
hibernatePropertiesFileContents
.append("hibernate.connection.driver_class=org.h2.Driver\n")
Expand All @@ -120,15 +116,15 @@ private void createHibernatePropertiesFile() throws Exception {
private void executeGenerateJavaTask() throws Exception {
GradleRunner gradleRunner = GradleRunner.create();
gradleRunner.forwardOutput();
gradleRunner.withProjectDir(projectDir);
gradleRunner.withProjectDir(getProjectDir());
gradleRunner.withPluginClasspath();
gradleRunner.withArguments("generateJava");
BuildResult buildResult = gradleRunner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
}

private void verifyProject() throws Exception {
File generatedOutputFolder = new File(projectDir, "app/generated-sources");
File generatedOutputFolder = new File(getProjectDir(), "app/generated-sources");
assertTrue(generatedOutputFolder.exists());
assertTrue(generatedOutputFolder.isDirectory());
assertEquals(1, generatedOutputFolder.list().length);
Expand All @@ -154,7 +150,7 @@ private void addH2DatabaseDependencyLine(StringBuffer gradleBuildFileContents) {
}

private String constructJdbcConnectionString() {
return "jdbc:h2:" + projectDir.getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
return "jdbc:h2:" + getProjectDir().getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
}

private String constructHibernateToolsPluginLine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import org.hibernate.tool.it.gradle.TestTemplate;

Expand All @@ -24,16 +23,13 @@ public class NoAnnotationsTest extends TestTemplate {
private static final List<String> GRADLE_INIT_PROJECT_ARGUMENTS = List.of(
"init", "--type", "java-application", "--dsl", "groovy", "--test-framework", "junit-jupiter", "--java-version", "17");

@TempDir
private File projectDir;

private File gradlePropertiesFile;
private File gradleBuildFile;
private File databaseFile;

@Test
public void testTutorial() throws Exception {
assertTrue(projectDir.exists());
assertTrue(getProjectDir().exists());
createGradleProject();
editGradleBuildFile();
editGradlePropertiesFile();
Expand All @@ -56,19 +52,19 @@ private void createGradleProject() throws Exception {
GradleRunner runner = GradleRunner.create();
runner.withArguments(GRADLE_INIT_PROJECT_ARGUMENTS);
runner.forwardOutput();
runner.withProjectDir(projectDir);
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(projectDir, "gradle.properties");
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
File appDir = new File(projectDir, "app");
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
gradleBuildFile = new File(appDir, "build.gradle");
assertTrue(gradleBuildFile.exists());
assertTrue(gradleBuildFile.isFile());
databaseFile = new File(projectDir, "database/test.mv.db");
databaseFile = new File(getProjectDir(), "database/test.mv.db");
assertFalse(databaseFile.exists());
}

Expand Down Expand Up @@ -105,7 +101,7 @@ private void createDatabase() throws Exception {
}

private void createHibernatePropertiesFile() throws Exception {
File hibernatePropertiesFile = new File(projectDir, "app/src/main/resources/hibernate.properties");
File hibernatePropertiesFile = new File(getProjectDir(), "app/src/main/resources/hibernate.properties");
StringBuffer hibernatePropertiesFileContents = new StringBuffer();
hibernatePropertiesFileContents
.append("hibernate.connection.driver_class=org.h2.Driver\n")
Expand All @@ -121,15 +117,15 @@ private void createHibernatePropertiesFile() throws Exception {
private void executeGenerateJavaTask() throws Exception {
GradleRunner gradleRunner = GradleRunner.create();
gradleRunner.forwardOutput();
gradleRunner.withProjectDir(projectDir);
gradleRunner.withProjectDir(getProjectDir());
gradleRunner.withPluginClasspath();
gradleRunner.withArguments("generateJava");
BuildResult buildResult = gradleRunner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
}

private void verifyProject() throws Exception {
File generatedOutputFolder = new File(projectDir, "app/generated-sources");
File generatedOutputFolder = new File(getProjectDir(), "app/generated-sources");
assertTrue(generatedOutputFolder.exists());
assertTrue(generatedOutputFolder.isDirectory());
assertEquals(1, generatedOutputFolder.list().length);
Expand Down Expand Up @@ -168,7 +164,7 @@ private void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {
}

private String constructJdbcConnectionString() {
return "jdbc:h2:" + projectDir.getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
return "jdbc:h2:" + getProjectDir().getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
}

private String constructHibernateToolsPluginLine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import org.hibernate.tool.it.gradle.TestTemplate;

Expand All @@ -23,16 +22,13 @@ public class NoGenerics extends TestTemplate {
private static final List<String> GRADLE_INIT_PROJECT_ARGUMENTS = List.of(
"init", "--type", "java-application", "--dsl", "groovy", "--test-framework", "junit-jupiter", "--java-version", "17");

@TempDir
private File projectDir;

private File gradlePropertiesFile;
private File gradleBuildFile;
private File databaseFile;

@Test
public void testTutorial() throws Exception {
assertTrue(projectDir.exists());
assertTrue(getProjectDir().exists());
createGradleProject();
editGradleBuildFile();
editGradlePropertiesFile();
Expand All @@ -46,19 +42,19 @@ private void createGradleProject() throws Exception {
GradleRunner runner = GradleRunner.create();
runner.withArguments(GRADLE_INIT_PROJECT_ARGUMENTS);
runner.forwardOutput();
runner.withProjectDir(projectDir);
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(projectDir, "gradle.properties");
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
File appDir = new File(projectDir, "app");
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
gradleBuildFile = new File(appDir, "build.gradle");
assertTrue(gradleBuildFile.exists());
assertTrue(gradleBuildFile.isFile());
databaseFile = new File(projectDir, "database/test.mv.db");
databaseFile = new File(getProjectDir(), "database/test.mv.db");
assertFalse(databaseFile.exists());
}

Expand Down Expand Up @@ -99,7 +95,7 @@ private void createDatabase() throws Exception {
}

private void createHibernatePropertiesFile() throws Exception {
File hibernatePropertiesFile = new File(projectDir, "app/src/main/resources/hibernate.properties");
File hibernatePropertiesFile = new File(getProjectDir(), "app/src/main/resources/hibernate.properties");
StringBuffer hibernatePropertiesFileContents = new StringBuffer();
hibernatePropertiesFileContents
.append("hibernate.connection.driver_class=org.h2.Driver\n")
Expand All @@ -115,15 +111,15 @@ private void createHibernatePropertiesFile() throws Exception {
private void executeGenerateJavaTask() throws Exception {
GradleRunner gradleRunner = GradleRunner.create();
gradleRunner.forwardOutput();
gradleRunner.withProjectDir(projectDir);
gradleRunner.withProjectDir(getProjectDir());
gradleRunner.withPluginClasspath();
gradleRunner.withArguments("generateJava");
BuildResult buildResult = gradleRunner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
}

private void verifyProject() throws Exception {
File generatedOutputFolder = new File(projectDir, "app/generated-sources");
File generatedOutputFolder = new File(getProjectDir(), "app/generated-sources");
assertTrue(generatedOutputFolder.exists());
assertTrue(generatedOutputFolder.isDirectory());
assertEquals(2, generatedOutputFolder.list().length);
Expand Down Expand Up @@ -168,7 +164,7 @@ private void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {
}

private String constructJdbcConnectionString() {
return "jdbc:h2:" + projectDir.getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
return "jdbc:h2:" + getProjectDir().getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
}

private String constructHibernateToolsPluginLine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import org.hibernate.tool.it.gradle.TestTemplate;

Expand All @@ -23,16 +22,13 @@ public class UseGenerics extends TestTemplate {
private static final List<String> GRADLE_INIT_PROJECT_ARGUMENTS = List.of(
"init", "--type", "java-application", "--dsl", "groovy", "--test-framework", "junit-jupiter", "--java-version", "17");

@TempDir
private File projectDir;

private File gradlePropertiesFile;
private File gradleBuildFile;
private File databaseFile;

@Test
public void testTutorial() throws Exception {
assertTrue(projectDir.exists());
assertTrue(getProjectDir().exists());
createGradleProject();
editGradleBuildFile();
editGradlePropertiesFile();
Expand All @@ -46,19 +42,19 @@ private void createGradleProject() throws Exception {
GradleRunner runner = GradleRunner.create();
runner.withArguments(GRADLE_INIT_PROJECT_ARGUMENTS);
runner.forwardOutput();
runner.withProjectDir(projectDir);
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(projectDir, "gradle.properties");
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
File appDir = new File(projectDir, "app");
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
gradleBuildFile = new File(appDir, "build.gradle");
assertTrue(gradleBuildFile.exists());
assertTrue(gradleBuildFile.isFile());
databaseFile = new File(projectDir, "database/test.mv.db");
databaseFile = new File(getProjectDir(), "database/test.mv.db");
assertFalse(databaseFile.exists());
}

Expand Down Expand Up @@ -98,7 +94,7 @@ private void createDatabase() throws Exception {
}

private void createHibernatePropertiesFile() throws Exception {
File hibernatePropertiesFile = new File(projectDir, "app/src/main/resources/hibernate.properties");
File hibernatePropertiesFile = new File(getProjectDir(), "app/src/main/resources/hibernate.properties");
StringBuffer hibernatePropertiesFileContents = new StringBuffer();
hibernatePropertiesFileContents
.append("hibernate.connection.driver_class=org.h2.Driver\n")
Expand All @@ -114,15 +110,15 @@ private void createHibernatePropertiesFile() throws Exception {
private void executeGenerateJavaTask() throws Exception {
GradleRunner gradleRunner = GradleRunner.create();
gradleRunner.forwardOutput();
gradleRunner.withProjectDir(projectDir);
gradleRunner.withProjectDir(getProjectDir());
gradleRunner.withPluginClasspath();
gradleRunner.withArguments("generateJava");
BuildResult buildResult = gradleRunner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
}

private void verifyProject() throws Exception {
File generatedOutputFolder = new File(projectDir, "app/generated-sources");
File generatedOutputFolder = new File(getProjectDir(), "app/generated-sources");
assertTrue(generatedOutputFolder.exists());
assertTrue(generatedOutputFolder.isDirectory());
assertEquals(2, generatedOutputFolder.list().length);
Expand Down Expand Up @@ -154,7 +150,7 @@ private void addH2DatabaseDependencyLine(StringBuffer gradleBuildFileContents) {
}

private String constructJdbcConnectionString() {
return "jdbc:h2:" + projectDir.getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
return "jdbc:h2:" + getProjectDir().getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
}

private String constructHibernateToolsPluginLine() {
Expand Down
Loading