Files
openide/jvm/jvm-analysis-java-tests/testSrc/com/intellij/codeInspection/tests/java/JavaSystemGetPropertyInspectionTest.kt
Bart van Helvert ba513a4d88 [jvm] Rename shared.testFramework to internal.TestFramework
To better highlight that this test framework is for internal usage only. #IDEA-334017

GitOrigin-RevId: c491de2411cdffd6eee3e97a6273982560572f4b
2023-10-11 23:39:50 +00:00

89 lines
2.7 KiB
Kotlin

package com.intellij.codeInspection.tests.java
import com.intellij.jvm.analysis.internal.testFramework.SystemGetPropertyInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
class JavaSystemGetPropertyInspectionTest : SystemGetPropertyInspectionTestBase() {
fun `test highlighting`() {
myFixture.testHighlighting(JvmLanguage.JAVA, """
class Foo {
public static void bar() {
System.<warning descr="Call 'getProperty' can be simplified for 'file.separator'">getProperty</warning>("file.separator");
System.<warning descr="Call 'getProperty' can be simplified for 'path.separator'">getProperty</warning>("path.separator");
System.<warning descr="Call 'getProperty' can be simplified for 'line.separator'">getProperty</warning>("line.separator");
System.<warning descr="Call 'getProperty' can be simplified for 'file.encoding'">getProperty</warning>("file.encoding");
}
}
""".trimIndent())
}
fun `test quickfix file-separator`() {
myFixture.testQuickFix(JvmLanguage.JAVA, """
class Foo {
fun bar() {
System.getPrope<caret>rty("file.separator");
}
}
""".trimIndent(), """
import java.nio.file.FileSystems;
class Foo {
fun bar() {
FileSystems.getDefault().getSeparator();
}
}
""".trimIndent(), "Replace with 'java.nio.file.FileSystems.getDefault().getSeparator()'", true)
}
fun `test quickfix path-separator`() {
myFixture.testQuickFix(JvmLanguage.JAVA, """
class Foo {
fun bar() {
System.getPrope<caret>rty("path.separator");
}
}
""".trimIndent(), """
import java.io.File;
class Foo {
fun bar() {
File.pathSeparator;
}
}
""".trimIndent(), "Replace with 'java.io.File.pathSeparator'", true)
}
fun `test quickfix line-separator`() {
myFixture.testQuickFix(JvmLanguage.JAVA, """
class Foo {
fun bar() {
System.getPrope<caret>rty("line.separator");
}
}
""".trimIndent(), """
class Foo {
fun bar() {
System.lineSeparator();
}
}
""".trimIndent(), "Replace with 'java.lang.System.lineSeparator()'", true)
}
fun `test quickfix file-encoding`() {
myFixture.testQuickFix(JvmLanguage.JAVA, """
class Foo {
fun bar() {
System.getPrope<caret>rty("file.encoding");
}
}
""".trimIndent(), """
import java.nio.charset.Charset;
class Foo {
fun bar() {
Charset.defaultCharset().displayName();
}
}
""".trimIndent(), "Replace with 'java.nio.charset.Charset.defaultCharset().displayName()'", true)
}
}