From 26523a7e5f9a4c4df50bd85bce993513dade322b Mon Sep 17 00:00:00 2001 From: "Andrei.Kuznetsov" Date: Sun, 25 Feb 2024 22:37:22 +0100 Subject: [PATCH] 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 --- .../MavenCompatibilityProjectImportingTest.kt | 24 +++++++----- .../idea/maven/dom/MavenDomAnnotatorTest.kt | 10 ++--- .../maven/dom/MavenDomPathWithPropertyTest.kt | 8 ++-- .../dom/MavenModelReadingAndWritingTest.kt | 12 +++--- .../MavenModuleCompletionAndResolutionTest.kt | 37 ++++++++++--------- .../maven/dom/MavenPomXmlDocumentationTest.kt | 6 +-- .../maven/dom/MavenPropertyFindUsagesTest.kt | 23 ++++++------ .../MavenPropertyInActivationSectionTest.kt | 6 +-- .../idea/maven/dom/MavenPropertyRenameTest.kt | 20 +++++----- .../maven/dom/MavenPropertyResolverTest.kt | 33 +++++++++-------- .../dom/MavenRelativePathResolutionTest.kt | 10 ++--- .../maven/dom/MavenSuperNavigationTest.kt | 14 +++---- .../MavenArtifactCoordinatesHelperTest.kt | 6 +-- .../maven/execution/MavenJUnitPatcherTest.kt | 31 ++++++++-------- .../importing/MavenEncodingImportingTest.kt | 19 +++++----- .../idea/maven/indices/MavenSearcherTest.kt | 14 +++---- .../MavenAddDependencyIntentionTest.kt | 8 ++-- .../MavenModuleReferenceSearcherTest.kt | 18 ++++----- .../idea/maven/search/MavenSearchTest.kt | 6 +-- 19 files changed, 157 insertions(+), 148 deletions(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt index 94c7f8bbe242..998928cecbcc 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt @@ -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", """ @@ -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(""" test project diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomAnnotatorTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomAnnotatorTest.kt index 6f53ac75968f..c82447ea21f6 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomAnnotatorTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomAnnotatorTest.kt @@ -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", """ test @@ -61,7 +61,7 @@ class MavenDomAnnotatorTest : MavenDomTestCase() { } @Test - fun testAnnotateDependency() = runBlocking { + fun testAnnotateDependency() = runBlocking(Dispatchers.EDT) { val modulePom = createModulePom("m", """ test @@ -112,7 +112,7 @@ class MavenDomAnnotatorTest : MavenDomTestCase() { } @Test - fun testAnnotateDependencyWithEmptyRelativePath() = runBlocking { + fun testAnnotateDependencyWithEmptyRelativePath() = runBlocking(Dispatchers.EDT) { val modulePom = createModulePom("m", """ test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.kt index 44a2c4d472ae..806427b50337 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.kt @@ -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( """ test @@ -57,7 +57,7 @@ class MavenDomPathWithPropertyTest : MavenDomTestCase() { } @Test - fun testCompletionDirectoriesOnly() = runBlocking { + fun testCompletionDirectoriesOnly() = runBlocking(Dispatchers.EDT) { createProjectPom( """ test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModelReadingAndWritingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModelReadingAndWritingTest.kt index 9a90f76a64a0..823f2487ec55 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModelReadingAndWritingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModelReadingAndWritingTest.kt @@ -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 diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModuleCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModuleCompletionAndResolutionTest.kt index 31937b084393..895a9ffd1579 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModuleCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenModuleCompletionAndResolutionTest.kt @@ -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(""" test project @@ -93,7 +94,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testDoesNotCompeteIfThereIsNoModules() = runBlocking { + fun testDoesNotCompeteIfThereIsNoModules() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -116,7 +117,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testIncludesAllThePomsAvailable() = runBlocking { + fun testIncludesAllThePomsAvailable() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -153,7 +154,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testResolution() = runBlocking { + fun testResolution() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -221,7 +222,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testResolutionWithSlashes() = runBlocking { + fun testResolutionWithSlashes() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -267,7 +268,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testResolutionWithProperties() = runBlocking { + fun testResolutionWithProperties() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -322,7 +323,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreatePomQuickFix() = runBlocking { + fun testCreatePomQuickFix() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -365,7 +366,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreatePomQuickFixCustomPomFileName() = runBlocking { + fun testCreatePomQuickFixCustomPomFileName() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -408,7 +409,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreatePomQuickFixInDotXmlFolder() = runBlocking { + fun testCreatePomQuickFixInDotXmlFolder() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -452,7 +453,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreatePomQuickFixTakesGroupAndVersionFromSuperParent() = runBlocking { + fun testCreatePomQuickFixTakesGroupAndVersionFromSuperParent() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -498,7 +499,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreatePomQuickFixWithProperties() = runBlocking { + fun testCreatePomQuickFixWithProperties() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -529,7 +530,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreatePomQuickFixTakesDefaultGroupAndVersionIfNothingToOffer() = runBlocking { + fun testCreatePomQuickFixTakesDefaultGroupAndVersionIfNothingToOffer() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -569,7 +570,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreateModuleWithParentQuickFix() = runBlocking { + fun testCreateModuleWithParentQuickFix() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -617,7 +618,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreateModuleWithParentQuickFix2() = runBlocking { + fun testCreateModuleWithParentQuickFix2() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -666,7 +667,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testCreateModuleWithParentQuickFix3() = runBlocking { + fun testCreateModuleWithParentQuickFix3() = runBlocking(Dispatchers.EDT) { val parentPom = createModulePom("parent", """ test @@ -718,7 +719,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testDoesNotShowCreatePomQuickFixForEmptyModuleTag() = runBlocking { + fun testDoesNotShowCreatePomQuickFixForEmptyModuleTag() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -741,7 +742,7 @@ class MavenModuleCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { } @Test - fun testDoesNotShowCreatePomQuickFixExistingModule() = runBlocking { + fun testDoesNotShowCreatePomQuickFixExistingModule() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPomXmlDocumentationTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPomXmlDocumentationTest.kt index 0cb88bfd3d5e..8b1dc9156f60 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPomXmlDocumentationTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPomXmlDocumentationTest.kt @@ -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( """ test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyFindUsagesTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyFindUsagesTest.kt index 4b497c5c5615..e0bffd15910b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyFindUsagesTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyFindUsagesTest.kt @@ -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(""" test module1 @@ -34,7 +35,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() { } @Test - fun testFindModelPropertyFromReferenceWithDifferentQualifiers() = runBlocking { + fun testFindModelPropertyFromReferenceWithDifferentQualifiers() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -49,7 +50,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() { } @Test - fun testFindUsagesFromTag() = runBlocking { + fun testFindUsagesFromTag() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -64,7 +65,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() { } @Test - fun testFindUsagesFromTagValue() = runBlocking { + fun testFindUsagesFromTagValue() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -76,7 +77,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() { } @Test - fun testFindUsagesFromProperty() = runBlocking { + fun testFindUsagesFromProperty() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -91,7 +92,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() { } @Test - fun testFindUsagesForEnvProperty() = runBlocking { + fun testFindUsagesForEnvProperty() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -104,7 +105,7 @@ class MavenPropertyFindUsagesTest : MavenDomTestCase() { } @Test - fun testFindUsagesForSystemProperty() = runBlocking { + fun testFindUsagesForSystemProperty() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -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(""" test module1 diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.kt index 41b4426b7ffa..d087d0228b58 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.kt @@ -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( """ example diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyRenameTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyRenameTest.kt index 570a75aa936a..995c5fa9a6d3 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyRenameTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyRenameTest.kt @@ -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(""" test @@ -18,7 +18,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testRenamingPropertyTag() = runBlocking { + fun testRenamingPropertyTag() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -42,7 +42,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testDoNotRuinTextAroundTheReferenceWhenRenaming() = runBlocking { + fun testDoNotRuinTextAroundTheReferenceWhenRenaming() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -66,7 +66,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testRenamingChangesTheReferenceAccordingly() = runBlocking { + fun testRenamingChangesTheReferenceAccordingly() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -101,7 +101,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testRenamingPropertyFromReference() = runBlocking { + fun testRenamingPropertyFromReference() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -125,7 +125,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testDoNotRenameModelProperties() = runBlocking { + fun testDoNotRenameModelProperties() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -138,7 +138,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testDoNotRenameModelPropertiesFromReference() = runBlocking { + fun testDoNotRenameModelPropertiesFromReference() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 @@ -151,7 +151,7 @@ class MavenPropertyRenameTest : MavenDomTestCase() { } @Test - fun testDoNotRenameModelPropertiesTag() = runBlocking { + fun testDoNotRenameModelPropertiesTag() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test module1 diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyResolverTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyResolverTest.kt index 5dcfc0a86a92..c84adac5e8c2 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyResolverTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyResolverTest.kt @@ -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(""" test project @@ -40,7 +41,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testResolvingProjectParentAttributes() = runBlocking { + fun testResolvingProjectParentAttributes() = runBlocking(Dispatchers.EDT) { val modulePom = createModulePom("test", """ test @@ -67,7 +68,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testResolvingAbsentProperties() = runBlocking { + fun testResolvingAbsentProperties() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -78,7 +79,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testResolvingProjectDirectories() = runBlocking { + fun testResolvingProjectDirectories() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -92,7 +93,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testResolvingProjectAndParentProperties() = runBlocking { + fun testResolvingProjectAndParentProperties() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -133,7 +134,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testProjectPropertiesRecursively() = runBlocking { + fun testProjectPropertiesRecursively() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -153,7 +154,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testDoNotGoIntoInfiniteRecursion() = runBlocking { + fun testDoNotGoIntoInfiniteRecursion() = runBlocking(Dispatchers.EDT) { Assume.assumeTrue(isWorkspaceImport) createProjectPom(""" test @@ -176,7 +177,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testSophisticatedPropertyNameDoesNotBreakResolver() = runBlocking { + fun testSophisticatedPropertyNameDoesNotBreakResolver() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -188,7 +189,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testProjectPropertiesWithProfiles() = runBlocking { + fun testProjectPropertiesWithProfiles() = runBlocking(Dispatchers.EDT) { createProjectPom(""" test project @@ -223,7 +224,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testResolvingBasedirProperties() = runBlocking { + fun testResolvingBasedirProperties() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -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(""" test project @@ -263,7 +264,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testIncompleteProperties() = runBlocking { + fun testIncompleteProperties() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -276,7 +277,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testUncomittedProperties() = runBlocking { + fun testUncomittedProperties() = runBlocking(Dispatchers.EDT) { importProjectAsync(""" test project @@ -301,7 +302,7 @@ class MavenPropertyResolverTest : MavenMultiVersionImportingTestCase() { } @Test - fun testChainResolvePropertiesForFileWhichIsNotAProjectPom() = runBlocking { + fun testChainResolvePropertiesForFileWhichIsNotAProjectPom() = runBlocking(Dispatchers.EDT) { val file = createProjectSubFile("../some.pom", """ diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt index fd226dc50163..948f7011b920 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt @@ -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(""" test @@ -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 @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() diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSuperNavigationTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSuperNavigationTest.kt index 11b3e935684d..25e54d25156d 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSuperNavigationTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSuperNavigationTest.kt @@ -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( """ test @@ -59,7 +59,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() { } @Test - fun testNavigationToManagingPluginWithoutModules() = runBlocking { + fun testNavigationToManagingPluginWithoutModules() = runBlocking(Dispatchers.EDT) { configureProjectPom( """ test @@ -113,7 +113,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() { } @Test - fun testGotoToParentProject() = runBlocking { + fun testGotoToParentProject() = runBlocking(Dispatchers.EDT) { val parent = createProjectPom( """ test @@ -144,7 +144,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() { } @Test - fun testNavigationToManagingDependencyWithModules() = runBlocking { + fun testNavigationToManagingDependencyWithModules() = runBlocking(Dispatchers.EDT) { val parent = createProjectPom( """ test @@ -210,7 +210,7 @@ class MavenSuperNavigationTest : MavenDomTestCase() { } @Test - fun testNavigationToManagingPluginWithModules() = runBlocking { + fun testNavigationToManagingPluginWithModules() = runBlocking(Dispatchers.EDT) { val parent = createProjectPom( """ test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesHelperTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesHelperTest.kt index 2371c2da6a53..d66e267f71c6 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesHelperTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesHelperTest.kt @@ -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(""" group parent diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.kt index 8dab64d64d33..4b3d827ae5e6 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.kt @@ -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", """ test m @@ -119,7 +120,7 @@ class MavenJUnitPatcherTest : MavenMultiVersionImportingTestCase() { @Test @Throws(CantRunException::class) - fun ExcludeClassPathElement() { + fun ExcludeClassPathElement() = runBlocking(Dispatchers.EDT){ val excludeSpecifications = arrayOf( """ @@ -191,7 +192,7 @@ org.jetbrains:annotations @Test @Throws(CantRunException::class) - fun ExcludeScope() { + fun ExcludeScope() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 @@ -238,7 +239,7 @@ org.jetbrains:annotations } @Test - fun AddClassPath() = runBlocking { + fun AddClassPath() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 @@ -272,7 +273,7 @@ org.jetbrains:annotations } @Test - fun ArgList() = runBlocking { + fun ArgList() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 @@ -307,7 +308,7 @@ org.jetbrains:annotations } @Test - fun IgnoreJaCoCoOption() = runBlocking { + fun IgnoreJaCoCoOption() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ testm11 @@ -342,7 +343,7 @@ org.jetbrains:annotations } @Test - fun ImplicitArgLine() = runBlocking { + fun ImplicitArgLine() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ testm11 -Dfoo=${'$'}{version} @@ -370,7 +371,7 @@ org.jetbrains:annotations } @Test - fun VmPropertiesResolve() = runBlocking { + fun VmPropertiesResolve() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 @@ -408,7 +409,7 @@ org.jetbrains:annotations } @Test - fun ArgLineLateReplacement() = runBlocking { + fun ArgLineLateReplacement() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 @@ -437,7 +438,7 @@ org.jetbrains:annotations } @Test - fun ArgLineLateReplacementParentProperty() = runBlocking { + fun ArgLineLateReplacementParentProperty() = runBlocking(Dispatchers.EDT) { createProjectPom( """ test @@ -493,7 +494,7 @@ org.jetbrains:annotations } @Test - fun ArgLineRefersAnotherProperty() = runBlocking { + fun ArgLineRefersAnotherProperty() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 @@ -526,7 +527,7 @@ org.jetbrains:annotations } @Test - fun ArgLineProperty() = runBlocking { + fun ArgLineProperty() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ testm11 -DsomeProp=Hello @@ -545,7 +546,7 @@ org.jetbrains:annotations } @Test - fun ResolvePropertiesUsingAt() = runBlocking { + fun ResolvePropertiesUsingAt() = runBlocking(Dispatchers.EDT) { val m1 = createModulePom("m1", """ test m1 diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenEncodingImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenEncodingImportingTest.kt index d126e1dc54a3..eba85326775e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenEncodingImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenEncodingImportingTest.kt @@ -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("""test project @@ -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("""test @@ -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("""test project @@ -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("""test project @@ -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", """ test @@ -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", """ test @@ -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", """ test @@ -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("""test project 1 diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.kt index b207decb66f5..e989d045169d 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.kt @@ -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) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/intentions/MavenAddDependencyIntentionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/intentions/MavenAddDependencyIntentionTest.kt index 1319bedb9c63..98f85d150087 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/intentions/MavenAddDependencyIntentionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/intentions/MavenAddDependencyIntentionTest.kt @@ -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("test" + "project" + @@ -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) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenModuleReferenceSearcherTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenModuleReferenceSearcherTest.kt index 0fcadfe13a9b..cc8916ffb686 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenModuleReferenceSearcherTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenModuleReferenceSearcherTest.kt @@ -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(""" group parent @@ -50,7 +50,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() { } @Test - fun testParentDirectoryRenameModuleReferenceChanged() = runBlocking { + fun testParentDirectoryRenameModuleReferenceChanged() = runBlocking(Dispatchers.EDT) { val parentFile = createProjectPom(""" group parent @@ -84,7 +84,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() { } @Test - fun testDirectoryRenameModuleRelativeReferenceChanged() = runBlocking { + fun testDirectoryRenameModuleRelativeReferenceChanged() = runBlocking(Dispatchers.EDT) { val parentFile = createProjectPom(""" group parent @@ -118,7 +118,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() { } @Test - fun testDirectoryRenameModuleParentPathReferenceChanged() = runBlocking { + fun testDirectoryRenameModuleParentPathReferenceChanged() = runBlocking(Dispatchers.EDT) { val parentFile = createProjectPom(""" group parent @@ -162,7 +162,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() { } @Test - fun testDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking { + fun testDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking(Dispatchers.EDT) { val parentFile = createProjectPom(""" group parent @@ -196,7 +196,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() { } @Test - fun testParentDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking { + fun testParentDirectoryRenameModuleWeirdNameReferenceChanged() = runBlocking(Dispatchers.EDT) { val parentFile = createProjectPom(""" group parent @@ -231,7 +231,7 @@ class MavenModuleReferenceSearcherTest : MavenDomTestCase() { @Test - fun testIncorrectModuleNameWithNewLineRenameModuleReferenceChanged() = runBlocking { + fun testIncorrectModuleNameWithNewLineRenameModuleReferenceChanged() = runBlocking(Dispatchers.EDT) { val parentFile = createProjectPom(""" group parent diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenSearchTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenSearchTest.kt index 6a445ab54f79..5adcd73c6ce4 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenSearchTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/search/MavenSearchTest.kt @@ -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("""test p1 pom