IJPL-578 maven: use runBlocking(Dispatchers.EDT) from background thread instead of runBlocking in EDT thread

Otherwise, dumb mode will never end after importing the project (we need WA and EDT to finish dumb mode)

GitOrigin-RevId: 27624360ee48dba842d0636f50f4d8ba30a74a75
This commit is contained in:
Andrei.Kuznetsov
2024-02-25 22:37:22 +01:00
committed by intellij-monorepo-bot
parent 308b3daabd
commit 26523a7e5f
19 changed files with 157 additions and 148 deletions

View File

@@ -3,10 +3,12 @@ package org.jetbrains.idea.maven.compatibility
import com.intellij.maven.testFramework.MavenImportingTestCase
import com.intellij.maven.testFramework.MavenWrapperTestFixture
import com.intellij.openapi.application.EDT
import com.intellij.openapi.module.LanguageLevelUtil
import com.intellij.openapi.util.text.StringUtil
import com.intellij.pom.java.LanguageLevel
import com.intellij.util.text.VersionComparatorUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.MavenCustomRepositoryHelper
import org.jetbrains.idea.maven.model.MavenProjectProblem
@@ -26,6 +28,8 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
@JvmField
var myMavenVersion: String? = null
override fun runInDispatchThread(): Boolean = false
private fun assumeVersionMoreThan(version: String) {
Assume.assumeTrue("Version should be more than $version", VersionComparatorUtil.compare(myMavenVersion, version) > 0)
}
@@ -44,7 +48,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Before
fun before() {
fun before() = runBlocking(Dispatchers.EDT) {
myWrapperTestFixture = MavenWrapperTestFixture(project, myMavenVersion)
myWrapperTestFixture!!.setUp()
@@ -55,13 +59,13 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@After
fun after() {
fun after() = runBlocking(Dispatchers.EDT) {
myWrapperTestFixture!!.tearDown()
}
@Test
fun testExceptionsFromMavenExtensionsAreReportedAsProblems() = runBlocking {
fun testExceptionsFromMavenExtensionsAreReportedAsProblems() = runBlocking(Dispatchers.EDT) {
assumeVersionAtLeast("3.1.0")
val helper = MavenCustomRepositoryHelper(dir, "plugins")
repositoryPath = helper.getTestDataPath("plugins")
@@ -99,7 +103,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testSmokeImport() = runBlocking {
fun testSmokeImport() = runBlocking(Dispatchers.EDT) {
assertCorrectVersion()
importProjectAsync("""
@@ -113,7 +117,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testSmokeImportWithUnknownExtension() = runBlocking {
fun testSmokeImportWithUnknownExtension() = runBlocking(Dispatchers.EDT) {
assertCorrectVersion()
createProjectSubFile(".mvn/extensions.xml", """
<extensions>
@@ -164,7 +168,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testInterpolateModel() = runBlocking {
fun testInterpolateModel() = runBlocking(Dispatchers.EDT) {
assertCorrectVersion()
importProjectAsync("""
@@ -189,7 +193,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testImportProjectProperties() = runBlocking {
fun testImportProjectProperties() = runBlocking(Dispatchers.EDT) {
assumeVersionMoreThan("3.0.3")
assertCorrectVersion()
@@ -230,7 +234,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testImportAddedProjectProperties() = runBlocking {
fun testImportAddedProjectProperties() = runBlocking(Dispatchers.EDT) {
assumeVersionMoreThan("3.0.3")
assumeVersionNot("3.6.0")
@@ -306,7 +310,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testImportSubProjectWithPropertyInParent() = runBlocking {
fun testImportSubProjectWithPropertyInParent() = runBlocking(Dispatchers.EDT) {
assumeVersionMoreThan("3.0.3")
assertCorrectVersion()
@@ -337,7 +341,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() {
}
@Test
fun testLanguageLevelWhenSourceLanguageLevelIsNotSpecified() = runBlocking {
fun testLanguageLevelWhenSourceLanguageLevelIsNotSpecified() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>

View File

@@ -2,16 +2,16 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenDomAnnotatorTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
@Test
fun testAnnotatePlugin() = runBlocking {
fun testAnnotatePlugin() = runBlocking(Dispatchers.EDT) {
val modulePom = createModulePom("m", """
<parent>
<groupId>test</groupId>
@@ -61,7 +61,7 @@ class MavenDomAnnotatorTest : MavenDomTestCase() {
}
@Test
fun testAnnotateDependency() = runBlocking {
fun testAnnotateDependency() = runBlocking(Dispatchers.EDT) {
val modulePom = createModulePom("m", """
<parent>
<groupId>test</groupId>
@@ -112,7 +112,7 @@ class MavenDomAnnotatorTest : MavenDomTestCase() {
}
@Test
fun testAnnotateDependencyWithEmptyRelativePath() = runBlocking {
fun testAnnotateDependencyWithEmptyRelativePath() = runBlocking(Dispatchers.EDT) {
val modulePom = createModulePom("m", """
<parent>
<groupId>test</groupId>

View File

@@ -1,15 +1,15 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import com.intellij.psi.PsiManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenDomPathWithPropertyTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
@Test
fun testRename() = runBlocking {
fun testRename() = runBlocking(Dispatchers.EDT) {
importProjectAsync(
"""
<groupId>test</groupId>
@@ -57,7 +57,7 @@ class MavenDomPathWithPropertyTest : MavenDomTestCase() {
}
@Test
fun testCompletionDirectoriesOnly() = runBlocking {
fun testCompletionDirectoriesOnly() = runBlocking(Dispatchers.EDT) {
createProjectPom(
"""
<groupId>test</groupId>

View File

@@ -3,6 +3,7 @@ package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenMultiVersionImportingTestCase
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.EDT
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.vfs.VfsUtil
@@ -10,14 +11,13 @@ import com.intellij.psi.PsiManager
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.testFramework.UsefulTestCase
import com.intellij.util.IncorrectOperationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
import org.junit.Test
class MavenModelReadingAndWritingTest : MavenMultiVersionImportingTestCase() {
override fun runInDispatchThread() = true
override fun setUp() = runBlocking {
override fun setUp() = runBlocking(Dispatchers.EDT) {
super.setUp()
importProjectAsync("""
@@ -28,7 +28,7 @@ class MavenModelReadingAndWritingTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testReading() = runBlocking {
fun testReading() = runBlocking(Dispatchers.EDT) {
val model = domModel
assertEquals("test", model!!.getGroupId().getStringValue())
@@ -37,7 +37,7 @@ class MavenModelReadingAndWritingTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testWriting() = runBlocking {
fun testWriting() = runBlocking(Dispatchers.EDT) {
CommandProcessor.getInstance().executeCommand(project, {
ApplicationManager.getApplication().runWriteAction {
val model = domModel
@@ -63,7 +63,7 @@ class MavenModelReadingAndWritingTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testAddingADependency() = runBlocking {
fun testAddingADependency() = runBlocking(Dispatchers.EDT) {
CommandProcessor.getInstance().executeCommand(project, {
ApplicationManager.getApplication().runWriteAction {
val model = domModel

View File

@@ -15,16 +15,17 @@
*/
package org.jetbrains.idea.maven.dom
import com.intellij.openapi.application.EDT
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.psi.PsiDocumentManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
override fun runInDispatchThread() = true
@Test
fun testCompleteFromAllAvailableModules() = runBlocking {
fun testCompleteFromAllAvailableModules() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -93,7 +94,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testDoesNotCompeteIfThereIsNoModules() = runBlocking {
fun testDoesNotCompeteIfThereIsNoModules() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -116,7 +117,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testIncludesAllThePomsAvailable() = runBlocking {
fun testIncludesAllThePomsAvailable() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -153,7 +154,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testResolution() = runBlocking {
fun testResolution() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -221,7 +222,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testResolutionWithSlashes() = runBlocking {
fun testResolutionWithSlashes() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -267,7 +268,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testResolutionWithProperties() = runBlocking {
fun testResolutionWithProperties() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -322,7 +323,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreatePomQuickFix() = runBlocking {
fun testCreatePomQuickFix() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -365,7 +366,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreatePomQuickFixCustomPomFileName() = runBlocking {
fun testCreatePomQuickFixCustomPomFileName() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -408,7 +409,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreatePomQuickFixInDotXmlFolder() = runBlocking {
fun testCreatePomQuickFixInDotXmlFolder() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -452,7 +453,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreatePomQuickFixTakesGroupAndVersionFromSuperParent() = runBlocking {
fun testCreatePomQuickFixTakesGroupAndVersionFromSuperParent() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -498,7 +499,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreatePomQuickFixWithProperties() = runBlocking {
fun testCreatePomQuickFixWithProperties() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -529,7 +530,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreatePomQuickFixTakesDefaultGroupAndVersionIfNothingToOffer() = runBlocking {
fun testCreatePomQuickFixTakesDefaultGroupAndVersionIfNothingToOffer() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -569,7 +570,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreateModuleWithParentQuickFix() = runBlocking {
fun testCreateModuleWithParentQuickFix() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -617,7 +618,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreateModuleWithParentQuickFix2() = runBlocking {
fun testCreateModuleWithParentQuickFix2() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -666,7 +667,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testCreateModuleWithParentQuickFix3() = runBlocking {
fun testCreateModuleWithParentQuickFix3() = runBlocking(Dispatchers.EDT) {
val parentPom = createModulePom("parent",
"""
<groupId>test</groupId>
@@ -718,7 +719,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testDoesNotShowCreatePomQuickFixForEmptyModuleTag() = runBlocking {
fun testDoesNotShowCreatePomQuickFixForEmptyModuleTag() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -741,7 +742,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testDoesNotShowCreatePomQuickFixExistingModule() = runBlocking {
fun testDoesNotShowCreatePomQuickFixExistingModule() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>

View File

@@ -2,14 +2,14 @@ package org.jetbrains.idea.maven.dom
import com.intellij.codeInsight.documentation.DocumentationManager
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenPomXmlDocumentationTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
@Test
fun testDocumentation() = runBlocking {
fun testDocumentation() = runBlocking(Dispatchers.EDT) {
createProjectPom(
"""
<groupId>test</groupId>

View File

@@ -2,13 +2,14 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenPropertyFindUsagesTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
override fun setUp() = runBlocking {
override fun setUp() = runBlocking(Dispatchers.EDT) {
super.setUp()
importProjectAsync("""
@@ -19,7 +20,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindModelPropertyFromReference() = runBlocking {
fun testFindModelPropertyFromReference() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -34,7 +35,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindModelPropertyFromReferenceWithDifferentQualifiers() = runBlocking {
fun testFindModelPropertyFromReferenceWithDifferentQualifiers() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -49,7 +50,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindUsagesFromTag() = runBlocking {
fun testFindUsagesFromTag() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -64,7 +65,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindUsagesFromTagValue() = runBlocking {
fun testFindUsagesFromTagValue() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -76,7 +77,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindUsagesFromProperty() = runBlocking {
fun testFindUsagesFromProperty() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -91,7 +92,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindUsagesForEnvProperty() = runBlocking {
fun testFindUsagesForEnvProperty() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -104,7 +105,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindUsagesForSystemProperty() = runBlocking {
fun testFindUsagesForSystemProperty() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -117,7 +118,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testFindUsagesForSystemPropertyInFilteredResources() = runBlocking {
fun testFindUsagesForSystemPropertyInFilteredResources() = runBlocking(Dispatchers.EDT) {
createProjectSubDir("res")
importProjectAsync("""
@@ -143,7 +144,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() {
}
@Test
fun testHighlightingFromTag() = runBlocking {
fun testHighlightingFromTag() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>

View File

@@ -1,14 +1,14 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenPropertyInActivationSectionTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
@Test
fun testResolvePropertyFromActivationSection() = runBlocking {
fun testResolvePropertyFromActivationSection() = runBlocking(Dispatchers.EDT) {
importProjectAsync(
"""
<groupId>example</groupId>

View File

@@ -2,13 +2,13 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenPropertyRenameTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
override fun setUp() = runBlocking {
override fun setUp() = runBlocking(Dispatchers.EDT) {
super.setUp()
importProjectAsync("""
<groupId>test</groupId>
@@ -18,7 +18,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testRenamingPropertyTag() = runBlocking {
fun testRenamingPropertyTag() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -42,7 +42,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testDoNotRuinTextAroundTheReferenceWhenRenaming() = runBlocking {
fun testDoNotRuinTextAroundTheReferenceWhenRenaming() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -66,7 +66,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testRenamingChangesTheReferenceAccordingly() = runBlocking {
fun testRenamingChangesTheReferenceAccordingly() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -101,7 +101,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testRenamingPropertyFromReference() = runBlocking {
fun testRenamingPropertyFromReference() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -125,7 +125,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testDoNotRenameModelProperties() = runBlocking {
fun testDoNotRenameModelProperties() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -138,7 +138,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testDoNotRenameModelPropertiesFromReference() = runBlocking {
fun testDoNotRenameModelPropertiesFromReference() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>
@@ -151,7 +151,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() {
}
@Test
fun testDoNotRenameModelPropertiesTag() = runBlocking {
fun testDoNotRenameModelPropertiesTag() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>module1</artifactId>

View File

@@ -16,19 +16,20 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenMultiVersionImportingTestCase
import com.intellij.openapi.application.EDT
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiDocumentManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Assume
import org.junit.Test
import java.io.File
class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
override fun runInDispatchThread() = true
@Test
fun testResolvingProjectAttributes() = runBlocking {
fun testResolvingProjectAttributes() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -40,7 +41,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testResolvingProjectParentAttributes() = runBlocking {
fun testResolvingProjectParentAttributes() = runBlocking(Dispatchers.EDT) {
val modulePom = createModulePom("test",
"""
<groupId>test</groupId>
@@ -67,7 +68,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testResolvingAbsentProperties() = runBlocking {
fun testResolvingAbsentProperties() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -78,7 +79,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testResolvingProjectDirectories() = runBlocking {
fun testResolvingProjectDirectories() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -92,7 +93,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testResolvingProjectAndParentProperties() = runBlocking {
fun testResolvingProjectAndParentProperties() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -133,7 +134,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testProjectPropertiesRecursively() = runBlocking {
fun testProjectPropertiesRecursively() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -153,7 +154,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testDoNotGoIntoInfiniteRecursion() = runBlocking {
fun testDoNotGoIntoInfiniteRecursion() = runBlocking(Dispatchers.EDT) {
Assume.assumeTrue(isWorkspaceImport)
createProjectPom("""
<groupId>test</groupId>
@@ -176,7 +177,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testSophisticatedPropertyNameDoesNotBreakResolver() = runBlocking {
fun testSophisticatedPropertyNameDoesNotBreakResolver() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -188,7 +189,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testProjectPropertiesWithProfiles() = runBlocking {
fun testProjectPropertiesWithProfiles() = runBlocking(Dispatchers.EDT) {
createProjectPom("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -223,7 +224,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testResolvingBasedirProperties() = runBlocking {
fun testResolvingBasedirProperties() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -236,7 +237,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testResolvingSystemProperties() = runBlocking {
fun testResolvingSystemProperties() = runBlocking(Dispatchers.EDT) {
val javaHome = System.getProperty("java.home")
val tempDir = System.getenv(envVar)
@@ -251,7 +252,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testAllProperties() = runBlocking {
fun testAllProperties() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -263,7 +264,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testIncompleteProperties() = runBlocking {
fun testIncompleteProperties() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -276,7 +277,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testUncomittedProperties() = runBlocking {
fun testUncomittedProperties() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -301,7 +302,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() {
}
@Test
fun testChainResolvePropertiesForFileWhichIsNotAProjectPom() = runBlocking {
fun testChainResolvePropertiesForFileWhichIsNotAProjectPom() = runBlocking(Dispatchers.EDT) {
val file = createProjectSubFile("../some.pom",
"""
<project>

View File

@@ -1,17 +1,17 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.maven.dom
import com.intellij.openapi.application.EDT
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.psi.impl.source.xml.XmlFileImpl
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
import java.io.File
class MavenRelativePathResolutionTest : MavenDomWithIndicesTestCase() {
override fun runInDispatchThread() = true
override fun setUp() = runBlocking {
override fun setUp() = runBlocking(Dispatchers.EDT) {
super.setUp()
importProjectAsync("""
<groupId>test</groupId>
@@ -21,7 +21,7 @@ class MavenRelativePathResolutionTest : MavenDomWithIndicesTestCase() {
}
@Test
fun testParentRelativePathOutsideProjectRoot() = runBlocking {
fun testParentRelativePathOutsideProjectRoot() = runBlocking(Dispatchers.EDT) {
val file = myIndicesFixture!!.repositoryHelper.getTestData("local1/org/example/example/1.0/example-1.0.pom")
@@ -51,7 +51,7 @@ $relativePathUnixSeparator<caret></relativePath>
@Test
fun testParentRelativePathOutsideProjectRootWithDir() = runBlocking {
fun testParentRelativePathOutsideProjectRootWithDir() = runBlocking(Dispatchers.EDT) {
val file = myIndicesFixture!!.repositoryHelper.getTestData("local1/org/example/example/1.0/pom.xml")
val parentFile = file.getParentFile()

View File

@@ -2,14 +2,14 @@
package org.jetbrains.idea.maven.dom
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenSuperNavigationTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
@Test
fun testNavigationToManagingDependencyWithoutModules() = runBlocking {
fun testNavigationToManagingDependencyWithoutModules() = runBlocking(Dispatchers.EDT) {
configureProjectPom(
"""
<groupId>test</groupId>
@@ -59,7 +59,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() {
}
@Test
fun testNavigationToManagingPluginWithoutModules() = runBlocking {
fun testNavigationToManagingPluginWithoutModules() = runBlocking(Dispatchers.EDT) {
configureProjectPom(
"""
<groupId>test</groupId>
@@ -113,7 +113,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() {
}
@Test
fun testGotoToParentProject() = runBlocking {
fun testGotoToParentProject() = runBlocking(Dispatchers.EDT) {
val parent = createProjectPom(
"""
<groupId>test</groupId>
@@ -144,7 +144,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() {
}
@Test
fun testNavigationToManagingDependencyWithModules() = runBlocking {
fun testNavigationToManagingDependencyWithModules() = runBlocking(Dispatchers.EDT) {
val parent = createProjectPom(
"""
<groupId>test</groupId>
@@ -210,7 +210,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() {
}
@Test
fun testNavigationToManagingPluginWithModules() = runBlocking {
fun testNavigationToManagingPluginWithModules() = runBlocking(Dispatchers.EDT) {
val parent = createProjectPom(
"""
<groupId>test</groupId>

View File

@@ -2,17 +2,17 @@
package org.jetbrains.idea.maven.dom.converters
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import com.intellij.util.xml.impl.ConvertContextFactory
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.dom.MavenDomUtil
import org.jetbrains.idea.maven.dom.converters.MavenArtifactCoordinatesHelper.getMavenId
import org.junit.Test
class MavenArtifactCoordinatesHelperTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
@Test
fun testGetPluginVersionFromParentPluginManagement() = runBlocking {
fun testGetPluginVersionFromParentPluginManagement() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>

View File

@@ -18,9 +18,11 @@ package org.jetbrains.idea.maven.execution
import com.intellij.execution.CantRunException
import com.intellij.execution.configurations.JavaParameters
import com.intellij.maven.testFramework.MavenMultiVersionImportingTestCase
import com.intellij.openapi.application.EDT
import com.intellij.testFramework.IdeaTestUtil
import com.intellij.util.PathUtil
import com.intellij.util.containers.ContainerUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.intellij.lang.annotations.Language
import org.jetbrains.idea.maven.project.MavenProjectSettings
@@ -30,9 +32,8 @@ import java.nio.file.Paths
import kotlin.io.path.name
class MavenJUnitPatcherTest : MavenMultiVersionImportingTestCase() {
override fun runInDispatchThread() = true
@Throws(Exception::class)
override fun setUp() {
override fun setUp() = runBlocking(Dispatchers.EDT){
super.setUp()
MavenProjectSettings.getInstance(project).testRunningSettings.isPassArgLine = true
MavenProjectSettings.getInstance(project).testRunningSettings.isPassEnvironmentVariables = true
@@ -41,7 +42,7 @@ class MavenJUnitPatcherTest : MavenMultiVersionImportingTestCase() {
@Test
@Throws(CantRunException::class)
fun ExcludeProjectDependencyInClassPathElement() {
fun ExcludeProjectDependencyInClassPathElement() = runBlocking(Dispatchers.EDT) {
val m = createModulePom("m", """
<groupId>test</groupId>
<artifactId>m</artifactId>
@@ -119,7 +120,7 @@ class MavenJUnitPatcherTest : MavenMultiVersionImportingTestCase() {
@Test
@Throws(CantRunException::class)
fun ExcludeClassPathElement() {
fun ExcludeClassPathElement() = runBlocking(Dispatchers.EDT){
val excludeSpecifications = arrayOf(
"""
<classpathDependencyExcludes>
@@ -191,7 +192,7 @@ org.jetbrains:annotations
@Test
@Throws(CantRunException::class)
fun ExcludeScope() {
fun ExcludeScope() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>
@@ -238,7 +239,7 @@ org.jetbrains:annotations
}
@Test
fun AddClassPath() = runBlocking {
fun AddClassPath() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>
@@ -272,7 +273,7 @@ org.jetbrains:annotations
}
@Test
fun ArgList() = runBlocking {
fun ArgList() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>
@@ -307,7 +308,7 @@ org.jetbrains:annotations
}
@Test
fun IgnoreJaCoCoOption() = runBlocking {
fun IgnoreJaCoCoOption() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId><artifactId>m1</artifactId><version>1</version><build>
<plugins>
@@ -342,7 +343,7 @@ org.jetbrains:annotations
}
@Test
fun ImplicitArgLine() = runBlocking {
fun ImplicitArgLine() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId><artifactId>m1</artifactId><version>1</version><properties>
<argLine>-Dfoo=${'$'}{version}</argLine>
@@ -370,7 +371,7 @@ org.jetbrains:annotations
}
@Test
fun VmPropertiesResolve() = runBlocking {
fun VmPropertiesResolve() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>
@@ -408,7 +409,7 @@ org.jetbrains:annotations
}
@Test
fun ArgLineLateReplacement() = runBlocking {
fun ArgLineLateReplacement() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>
@@ -437,7 +438,7 @@ org.jetbrains:annotations
}
@Test
fun ArgLineLateReplacementParentProperty() = runBlocking {
fun ArgLineLateReplacementParentProperty() = runBlocking(Dispatchers.EDT) {
createProjectPom(
"""
<groupId>test</groupId>
@@ -493,7 +494,7 @@ org.jetbrains:annotations
}
@Test
fun ArgLineRefersAnotherProperty() = runBlocking {
fun ArgLineRefersAnotherProperty() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>
@@ -526,7 +527,7 @@ org.jetbrains:annotations
}
@Test
fun ArgLineProperty() = runBlocking {
fun ArgLineProperty() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId><artifactId>m1</artifactId><version>1</version><properties>
<argLine>-DsomeProp=Hello</argLine>
@@ -545,7 +546,7 @@ org.jetbrains:annotations
}
@Test
fun ResolvePropertiesUsingAt() = runBlocking {
fun ResolvePropertiesUsingAt() = runBlocking(Dispatchers.EDT) {
val m1 = createModulePom("m1", """
<groupId>test</groupId>
<artifactId>m1</artifactId>

View File

@@ -2,17 +2,18 @@
package org.jetbrains.idea.maven.importing
import com.intellij.maven.testFramework.MavenMultiVersionImportingTestCase
import com.intellij.openapi.application.EDT
import com.intellij.openapi.vfs.encoding.EncodingProjectManager
import junit.framework.TestCase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.project.MavenProjectsManager
import org.junit.Test
import java.nio.charset.StandardCharsets
class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
override fun runInDispatchThread() = true
@Test
fun testShouldSetEncodingForNewProject() = runBlocking {
fun testShouldSetEncodingForNewProject() = runBlocking(Dispatchers.EDT) {
val subFile = createProjectSubFile("src/main/java/MyClass.java")
importProjectAsync("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -25,7 +26,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
TestCase.assertEquals(StandardCharsets.ISO_8859_1, EncodingProjectManager.getInstance(project).getEncoding(subFile, true))
}
@Test fun testShouldSetDifferentEncodingForSourceAndResource() = runBlocking {
@Test fun testShouldSetDifferentEncodingForSourceAndResource() = runBlocking(Dispatchers.EDT) {
val srcFile = createProjectSubFile("src/main/java/MyClass.java")
val resFile = createProjectSubFile("src/main/resources/data.properties")
importProjectAsync("""<groupId>test</groupId>
@@ -52,7 +53,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
TestCase.assertEquals(StandardCharsets.UTF_16LE, EncodingProjectManager.getInstance(project).getEncoding(resFile, true))
}
@Test fun testShouldUseSrcEncodingForResFiles() = runBlocking {
@Test fun testShouldUseSrcEncodingForResFiles() = runBlocking(Dispatchers.EDT) {
val resFile = createProjectSubFile("src/main/resources/data.properties")
importProjectAsync("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -66,7 +67,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
TestCase.assertEquals(StandardCharsets.ISO_8859_1, EncodingProjectManager.getInstance(project).getEncoding(resFile, true))
}
@Test fun testShouldChangeEncoding() = runBlocking {
@Test fun testShouldChangeEncoding() = runBlocking(Dispatchers.EDT) {
val subFile = createProjectSubFile("src/main/java/MyClass.java")
importProjectAsync("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -89,7 +90,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
TestCase.assertEquals(StandardCharsets.ISO_8859_1, EncodingProjectManager.getInstance(project).getEncoding(subFile, true))
}
@Test fun testShouldSetEncodingPerProject() = runBlocking {
@Test fun testShouldSetEncodingPerProject() = runBlocking(Dispatchers.EDT) {
createModulePom("module1", """<parent>
<groupId>test</groupId>
@@ -130,7 +131,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
TestCase.assertEquals(StandardCharsets.ISO_8859_1, EncodingProjectManager.getInstance(project).getEncoding(subFile2, true))
}
@Test fun testShouldSetEncodingPerProjectInSubsequentImport() = runBlocking {
@Test fun testShouldSetEncodingPerProjectInSubsequentImport() = runBlocking(Dispatchers.EDT) {
createModulePom("module1", """
<parent>
<groupId>test</groupId>
@@ -182,7 +183,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
assertEquals(StandardCharsets.ISO_8859_1, EncodingProjectManager.getInstance(project).getEncoding(subFile2, true))
}
@Test fun testShouldSetEncodingToNewFiles() = runBlocking {
@Test fun testShouldSetEncodingToNewFiles() = runBlocking(Dispatchers.EDT) {
createModulePom("module1", """<parent>
<groupId>test</groupId>
@@ -223,7 +224,7 @@ class MavenEncodingImportingTest : MavenMultiVersionImportingTestCase() {
TestCase.assertEquals(StandardCharsets.ISO_8859_1, EncodingProjectManager.getInstance(project).getEncoding(subFile2, true))
}
@Test fun testShouldSetResourceEncodingAsProperties() = runBlocking {
@Test fun testShouldSetResourceEncodingAsProperties() = runBlocking(Dispatchers.EDT) {
importProjectAsync("""<groupId>test</groupId>
<artifactId>project</artifactId>
<version>1</version>

View File

@@ -15,6 +15,8 @@
*/
package org.jetbrains.idea.maven.indices
import com.intellij.openapi.application.EDT
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.indices.searcher.MavenLuceneIndexer
import org.jetbrains.idea.maven.model.MavenRepositoryInfo
@@ -22,8 +24,6 @@ import org.junit.Test
import java.util.*
class MavenSearcherTest : MavenIndicesTestCase() {
override fun runInDispatchThread() = true
private val JUNIT_VERSIONS = arrayOf("junit:junit:4.0", "junit:junit:3.8.2", "junit:junit:3.8.1")
private val JMOCK_VERSIONS = arrayOf("jmock:jmock:1.2.0", "jmock:jmock:1.1.0", "jmock:jmock:1.0.0")
private val COMMONS_IO_VERSIONS = arrayOf("commons-io:commons-io:2.4")
@@ -33,7 +33,7 @@ class MavenSearcherTest : MavenIndicesTestCase() {
@Throws(Exception::class)
override fun setUp() {
override fun setUp() = runBlocking(Dispatchers.EDT) {
super.setUp()
myIndicesFixture = MavenIndicesTestFixture(dir.toPath(), project, testRootDisposable)
myIndicesFixture.setUp()
@@ -46,7 +46,7 @@ class MavenSearcherTest : MavenIndicesTestCase() {
}
@Throws(Exception::class)
override fun tearDown() {
override fun tearDown() = runBlocking(Dispatchers.EDT) {
try {
myIndicesFixture.tearDown()
}
@@ -59,7 +59,7 @@ class MavenSearcherTest : MavenIndicesTestCase() {
}
@Test
fun testClassSearch() = runBlocking {
fun testClassSearch() = runBlocking(Dispatchers.EDT) {
assertClassSearchResults("TestCas",
"TestCase(junit.framework) junit:junit:4.0 junit:junit:3.8.2 junit:junit:3.8.1",
"TestCaseClassLoader(junit.runner) junit:junit:3.8.2 junit:junit:3.8.1")
@@ -109,7 +109,7 @@ class MavenSearcherTest : MavenIndicesTestCase() {
}
@Test
fun testArtifactSearch() = runBlocking {
fun testArtifactSearch() = runBlocking(Dispatchers.EDT) {
assertArtifactSearchResults("")
assertArtifactSearchResults("j:j", *(JMOCK_VERSIONS + JUNIT_VERSIONS))
assertArtifactSearchResults("junit", *JUNIT_VERSIONS)
@@ -125,7 +125,7 @@ class MavenSearcherTest : MavenIndicesTestCase() {
}
@Test
fun testArtifactSearchDash() = runBlocking {
fun testArtifactSearchDash() = runBlocking(Dispatchers.EDT) {
assertArtifactSearchResults("commons", *COMMONS_IO_VERSIONS)
assertArtifactSearchResults("commons-", *COMMONS_IO_VERSIONS)
assertArtifactSearchResults("commons-io", *COMMONS_IO_VERSIONS)

View File

@@ -1,17 +1,17 @@
package org.jetbrains.idea.maven.intentions
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import com.intellij.psi.PsiJavaCodeReferenceElement
import com.intellij.psi.util.PsiTreeUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.idea.maven.dom.intentions.AddMavenDependencyQuickFix
import org.junit.Test
import java.io.IOException
class MavenAddDependencyIntentionTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
override fun setUp() = runBlocking {
override fun setUp() = runBlocking(Dispatchers.EDT) {
super.setUp()
importProjectAsync("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
@@ -91,7 +91,7 @@ class MavenAddDependencyIntentionTest : MavenDomTestCase() {
}
@Throws(IOException::class)
private fun doTest(classText: String, referenceText: String?) {
private fun doTest(classText: String, referenceText: String?) = runBlocking(Dispatchers.EDT) {
val file = createProjectSubFile("src/main/java/A.java", classText)
fixture.configureFromExistingVirtualFile(file)

View File

@@ -2,22 +2,22 @@
package org.jetbrains.idea.maven.search
import com.intellij.maven.testFramework.MavenDomTestCase
import com.intellij.openapi.application.EDT
import com.intellij.psi.PsiDirectory
import com.intellij.psi.impl.file.PsiDirectoryFactory
import com.intellij.refactoring.rename.RenameDialog
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
override fun runInDispatchThread() = true
private fun renameDirectory(directory: PsiDirectory, newName: String) {
val renameDialog = RenameDialog(project, directory, directory, null)
renameDialog.performRename(newName)
}
@Test
fun testDirectoryRenameModuleReferenceChanged() = runBlocking {
fun testDirectoryRenameModuleReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>
@@ -50,7 +50,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
}
@Test
fun testParentDirectoryRenameModuleReferenceChanged() = runBlocking {
fun testParentDirectoryRenameModuleReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>
@@ -84,7 +84,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
}
@Test
fun testDirectoryRenameModuleRelativeReferenceChanged() = runBlocking {
fun testDirectoryRenameModuleRelativeReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>
@@ -118,7 +118,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
}
@Test
fun testDirectoryRenameModuleParentPathReferenceChanged() = runBlocking {
fun testDirectoryRenameModuleParentPathReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>
@@ -162,7 +162,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
}
@Test
fun testDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking {
fun testDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>
@@ -196,7 +196,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
}
@Test
fun testParentDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking {
fun testParentDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>
@@ -231,7 +231,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() {
@Test
fun testIncorrectModuleNameWithNewLineRenameModuleReferenceChanged() = runBlocking {
fun testIncorrectModuleNameWithNewLineRenameModuleReferenceChanged() = runBlocking(Dispatchers.EDT) {
val parentFile = createProjectPom("""
<groupId>group</groupId>
<artifactId>parent</artifactId>

View File

@@ -8,17 +8,17 @@ import com.intellij.mock.MockProgressIndicator
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
import com.intellij.openapi.application.EDT
import com.intellij.openapi.util.Disposer
import com.intellij.psi.PsiManager
import com.intellij.testFramework.UsefulTestCase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Test
class MavenSearchTest : MavenMultiVersionImportingTestCase() {
override fun runInDispatchThread() = true
@Test
fun `test searching POM files by module name`() = runBlocking {
fun `test searching POM files by module name`() = runBlocking(Dispatchers.EDT) {
createProjectPom("""<groupId>test</groupId>
<artifactId>p1</artifactId>
<packaging>pom</packaging>