mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Gradle|Exec] cleanup: migrate GradlePropertiesFileTest on Junit 5
GitOrigin-RevId: 7be25046c801fdde7d64db1233081c84665d2468
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d310222665
commit
8739d91fff
+11
-10
@@ -8,6 +8,7 @@ class GradlePropertiesFileTest : GradlePropertiesFileTestCase() {
|
||||
|
||||
@Test
|
||||
fun testEmptyProjectGradlePropertiesFile() {
|
||||
createGradlePropertiesFile {}
|
||||
assertGradlePropertiesFile {
|
||||
Assertions.assertNull(javaHomeProperty)
|
||||
Assertions.assertNull(gradleLoggingLevel)
|
||||
@@ -43,15 +44,15 @@ class GradlePropertiesFileTest : GradlePropertiesFileTestCase() {
|
||||
}
|
||||
assertGradlePropertiesFile {
|
||||
Assertions.assertEquals("javaHome", javaHomeProperty?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, javaHomeProperty?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), javaHomeProperty?.location)
|
||||
Assertions.assertEquals("info", gradleLoggingLevel?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, gradleLoggingLevel?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), gradleLoggingLevel?.location)
|
||||
Assertions.assertEquals(true, parallel?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, parallel?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), parallel?.location)
|
||||
Assertions.assertEquals(true, isolatedProjects?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, isolatedProjects?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), isolatedProjects?.location)
|
||||
Assertions.assertEquals( "-Xmx20G", jvmOptions?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, jvmOptions?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), jvmOptions?.location)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,15 +69,15 @@ class GradlePropertiesFileTest : GradlePropertiesFileTestCase() {
|
||||
}
|
||||
assertGradlePropertiesFile {
|
||||
Assertions.assertEquals("value2", javaHomeProperty?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, javaHomeProperty?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), javaHomeProperty?.location)
|
||||
Assertions.assertEquals("value3", gradleLoggingLevel?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, gradleLoggingLevel?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), gradleLoggingLevel?.location)
|
||||
Assertions.assertEquals(true, parallel?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, parallel?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), parallel?.location)
|
||||
Assertions.assertEquals(true, isolatedProjects?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, isolatedProjects?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), isolatedProjects?.location)
|
||||
Assertions.assertEquals("-Xmx20G", jvmOptions?.value)
|
||||
Assertions.assertEquals(gradlePropertiesPath, jvmOptions?.location)
|
||||
Assertions.assertEquals(projectPropertiesPath.toString(), jvmOptions?.location)
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-31
@@ -1,13 +1,9 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.gradle.properties
|
||||
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
import com.intellij.testFramework.fixtures.TempDirTestFixture
|
||||
import com.intellij.testFramework.junit5.TestApplication
|
||||
import com.intellij.util.io.createDirectories
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import com.intellij.util.io.createParentDirectories
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
import kotlin.io.path.outputStream
|
||||
@@ -15,40 +11,24 @@ import kotlin.io.path.outputStream
|
||||
@TestApplication
|
||||
abstract class GradlePropertiesFileTestCase {
|
||||
|
||||
private lateinit var fileFixture: TempDirTestFixture
|
||||
@TempDir
|
||||
private lateinit var rootPath: Path
|
||||
|
||||
private lateinit var externalProjectNioPath: Path
|
||||
private lateinit var gradlePropertiesNioPath: Path
|
||||
val projectPath: Path
|
||||
get() = rootPath.resolve("project")
|
||||
|
||||
val gradlePropertiesPath get() = gradlePropertiesNioPath.toString()
|
||||
|
||||
@BeforeEach
|
||||
fun setUpGradlePropertiesFileTestCase(testInfo: TestInfo) {
|
||||
fileFixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture()
|
||||
fileFixture.setUp()
|
||||
|
||||
val className = testInfo.testClass.get().simpleName
|
||||
val methodName = testInfo.testMethod.get().name
|
||||
|
||||
externalProjectNioPath = Path.of(fileFixture.tempDirPath, className, methodName, "project")
|
||||
gradlePropertiesNioPath = externalProjectNioPath.resolve(GRADLE_PROPERTIES_FILE_NAME)
|
||||
|
||||
externalProjectNioPath.createDirectories()
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDownGradlePropertiesFileTestCase() {
|
||||
fileFixture.tearDown()
|
||||
}
|
||||
val projectPropertiesPath: Path
|
||||
get() = projectPath.resolve(GRADLE_PROPERTIES_FILE_NAME)
|
||||
|
||||
fun createGradlePropertiesFile(configure: Properties.() -> Unit) {
|
||||
val properties = Properties()
|
||||
properties.configure()
|
||||
properties.store(gradlePropertiesNioPath.outputStream(), null)
|
||||
projectPropertiesPath.createParentDirectories()
|
||||
properties.store(projectPropertiesPath.outputStream(), null)
|
||||
}
|
||||
|
||||
fun assertGradlePropertiesFile(assertion: GradleProperties. () -> Unit) {
|
||||
val properties = GradlePropertiesFile.getProperties(null, externalProjectNioPath)
|
||||
val properties = GradlePropertiesFile.getProperties(null, projectPath)
|
||||
properties.assertion()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user