Skip to content

Commit 3e09374

Browse files
committed
HBX-3080: Refactor the Gradle integration tests to factor out common code
- Pull up method 'editGradlePropertiesFile()' Signed-off-by: Koen Aers <[email protected]>
1 parent 30e4f49 commit 3e09374

File tree

6 files changed

+12
-58
lines changed

6 files changed

+12
-58
lines changed

gradle/plugin/src/functionalTest/java/org/hibernate/tool/gradle/java/JpaDefaultTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ private void verifyDatabase() throws Exception {
4141
assertEquals("foo", resultSet.getString(2));
4242
}
4343

44-
private void editGradlePropertiesFile() throws Exception {
45-
// The Hibernate Tools Gradle plugin does not support the configuration cache.
46-
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
47-
// in the gradle.properties file.
48-
StringBuffer gradlePropertiesFileContents = new StringBuffer(
49-
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
50-
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
51-
gradlePropertiesFileContents.insert(pos, "#");
52-
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
53-
}
54-
5544
private void createDatabase() throws Exception {
5645
String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
5746
Connection connection = DriverManager.getConnection(constructJdbcConnectionString());

gradle/plugin/src/functionalTest/java/org/hibernate/tool/gradle/java/NoAnnotationsTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ private void verifyDatabase() throws Exception {
4141
assertEquals("foo", resultSet.getString(2));
4242
}
4343

44-
private void editGradlePropertiesFile() throws Exception {
45-
// The Hibernate Tools Gradle plugin does not support the configuration cache.
46-
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
47-
// in the gradle.properties file.
48-
StringBuffer gradlePropertiesFileContents = new StringBuffer(
49-
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
50-
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
51-
gradlePropertiesFileContents.insert(pos, "#");
52-
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
53-
}
54-
5544
private void createDatabase() throws Exception {
5645
String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
5746
Connection connection = DriverManager.getConnection(constructJdbcConnectionString());

gradle/plugin/src/functionalTest/java/org/hibernate/tool/gradle/java/NoGenerics.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ public void testTutorial() throws Exception {
3131
verifyProject();
3232
}
3333

34-
private void editGradlePropertiesFile() throws Exception {
35-
// The Hibernate Tools Gradle plugin does not support the configuration cache.
36-
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
37-
// in the gradle.properties file.
38-
StringBuffer gradlePropertiesFileContents = new StringBuffer(
39-
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
40-
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
41-
gradlePropertiesFileContents.insert(pos, "#");
42-
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
43-
}
44-
4534
private void createDatabase() throws Exception {
4635
String CREATE_PERSON_TABLE =
4736
"create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";

gradle/plugin/src/functionalTest/java/org/hibernate/tool/gradle/java/UseGenerics.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ public void testTutorial() throws Exception {
3131
verifyProject();
3232
}
3333

34-
private void editGradlePropertiesFile() throws Exception {
35-
// The Hibernate Tools Gradle plugin does not support the configuration cache.
36-
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
37-
// in the gradle.properties file.
38-
StringBuffer gradlePropertiesFileContents = new StringBuffer(
39-
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
40-
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
41-
gradlePropertiesFileContents.insert(pos, "#");
42-
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
43-
}
44-
4534
private void createDatabase() throws Exception {
4635
String CREATE_PERSON_TABLE =
4736
"create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";

gradle/plugin/src/functionalTest/java/org/hibernate/tool/gradle/tutorial/TutorialTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ private void verifyDatabase() throws Exception {
4141
assertEquals("foo", resultSet.getString(2));
4242
}
4343

44-
private void editGradlePropertiesFile() throws Exception {
45-
// The Hibernate Tools Gradle plugin does not support the configuration cache.
46-
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
47-
// in the gradle.properties file.
48-
StringBuffer gradlePropertiesFileContents = new StringBuffer(
49-
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
50-
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
51-
gradlePropertiesFileContents.insert(pos, "#");
52-
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
53-
}
54-
5544
private void createDatabase() throws Exception {
5645
String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
5746
Connection connection = DriverManager.getConnection(constructJdbcConnectionString());

gradle/plugin/src/functionalTest/java/org/hibernate/tool/it/gradle/TestTemplate.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ protected void editGradleBuildFile() throws Exception {
6161
Files.writeString(getGradleBuildFile().toPath(), gradleBuildFileContents.toString());
6262
}
6363

64+
protected void editGradlePropertiesFile() throws Exception {
65+
// The Hibernate Tools Gradle plugin does not support the configuration cache.
66+
// As this is enabled by default when initializing a new Gradle project, the setting needs to be commented out
67+
// in the gradle.properties file.
68+
StringBuffer gradlePropertiesFileContents = new StringBuffer(
69+
new String(Files.readAllBytes(getGradlePropertiesFile().toPath())));
70+
int pos = gradlePropertiesFileContents.indexOf("org.gradle.configuration-cache=true");
71+
gradlePropertiesFileContents.insert(pos, "#");
72+
Files.writeString(getGradlePropertiesFile().toPath(), gradlePropertiesFileContents.toString());
73+
}
74+
6475
protected void createHibernatePropertiesFile() throws Exception {
6576
File hibernatePropertiesFile = new File(getProjectDir(), "app/src/main/resources/hibernate.properties");
6677
StringBuffer hibernatePropertiesFileContents = new StringBuffer();
@@ -100,8 +111,6 @@ protected void addHibernateToolsPluginLine(StringBuffer gradleBuildFileContents)
100111
gradleBuildFileContents.insert(pos, constructHibernateToolsPluginLine() + "\n");
101112
}
102113

103-
protected void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {
104-
105-
}
114+
protected void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {}
106115

107116
}

0 commit comments

Comments
 (0)