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 @@ -23,7 +23,6 @@ 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");

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

Expand Down Expand Up @@ -55,9 +54,9 @@ private void createGradleProject() throws Exception {
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
setGradlePropertiesFile(new File(getProjectDir(), "gradle.properties"));
assertTrue(getGradlePropertiesFile().exists());
assertTrue(getGradlePropertiesFile().isFile());
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
Expand All @@ -81,10 +80,10 @@ private void editGradlePropertiesFile() throws Exception {
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
// in the gradle.properties file.
StringBuffer gradlePropertiesFileContents = new StringBuffer(
new String(Files.readAllBytes(gradlePropertiesFile.toPath())));
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
gradlePropertiesFileContents.insert(pos, "#");
Files.writeString(gradlePropertiesFile.toPath(), gradlePropertiesFileContents.toString());
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
}

private void createDatabase() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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");

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

Expand Down Expand Up @@ -55,9 +54,9 @@ private void createGradleProject() throws Exception {
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
setGradlePropertiesFile(new File(getProjectDir(), "gradle.properties"));
assertTrue(getGradlePropertiesFile().exists());
assertTrue(getGradlePropertiesFile().isFile());
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
Expand All @@ -82,10 +81,10 @@ private void editGradlePropertiesFile() throws Exception {
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
// in the gradle.properties file.
StringBuffer gradlePropertiesFileContents = new StringBuffer(
new String(Files.readAllBytes(gradlePropertiesFile.toPath())));
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
gradlePropertiesFileContents.insert(pos, "#");
Files.writeString(gradlePropertiesFile.toPath(), gradlePropertiesFileContents.toString());
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
}

private void createDatabase() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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");

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

Expand All @@ -45,9 +44,9 @@ private void createGradleProject() throws Exception {
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
setGradlePropertiesFile(new File(getProjectDir(), "gradle.properties"));
assertTrue(getGradlePropertiesFile().exists());
assertTrue(getGradlePropertiesFile().isFile());
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
Expand All @@ -72,10 +71,10 @@ private void editGradlePropertiesFile() throws Exception {
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
// in the gradle.properties file.
StringBuffer gradlePropertiesFileContents = new StringBuffer(
new String(Files.readAllBytes(gradlePropertiesFile.toPath())));
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
gradlePropertiesFileContents.insert(pos, "#");
Files.writeString(gradlePropertiesFile.toPath(), gradlePropertiesFileContents.toString());
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
}

private void createDatabase() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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");

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

Expand All @@ -45,9 +44,9 @@ private void createGradleProject() throws Exception {
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
setGradlePropertiesFile(new File(getProjectDir(), "gradle.properties"));
assertTrue(getGradlePropertiesFile().exists());
assertTrue(getGradlePropertiesFile().isFile());
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
Expand All @@ -71,10 +70,10 @@ private void editGradlePropertiesFile() throws Exception {
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
// in the gradle.properties file.
StringBuffer gradlePropertiesFileContents = new StringBuffer(
new String(Files.readAllBytes(gradlePropertiesFile.toPath())));
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
gradlePropertiesFileContents.insert(pos, "#");
Files.writeString(gradlePropertiesFile.toPath(), gradlePropertiesFileContents.toString());
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
}

private void createDatabase() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class TutorialTest 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");

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

Expand Down Expand Up @@ -55,9 +54,9 @@ private void createGradleProject() throws Exception {
runner.withProjectDir(getProjectDir());
BuildResult buildResult = runner.build();
assertTrue(buildResult.getOutput().contains("BUILD SUCCESSFUL"));
gradlePropertiesFile = new File(getProjectDir(), "gradle.properties");
assertTrue(gradlePropertiesFile.exists());
assertTrue(gradlePropertiesFile.isFile());
setGradlePropertiesFile(new File(getProjectDir(), "gradle.properties"));
assertTrue(getGradlePropertiesFile().exists());
assertTrue(getGradlePropertiesFile().isFile());
File appDir = new File(getProjectDir(), "app");
assertTrue(appDir.exists());
assertTrue(appDir.isDirectory());
Expand All @@ -81,10 +80,10 @@ private void editGradlePropertiesFile() throws Exception {
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
// in the gradle.properties file.
StringBuffer gradlePropertiesFileContents = new StringBuffer(
new String(Files.readAllBytes(gradlePropertiesFile.toPath())));
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
gradlePropertiesFileContents.insert(pos, "#");
Files.writeString(gradlePropertiesFile.toPath(), gradlePropertiesFileContents.toString());
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
}

private void createDatabase() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ public class TestTemplate {
@TempDir
private File projectDir;

private File gradlePropertiesFile;

protected File getProjectDir() {
return projectDir;
}

protected File getGradlePropertiesFile() {
return gradlePropertiesFile;
}

protected void setGradlePropertiesFile(File f) {
this.gradlePropertiesFile = f;
}

}