mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
IJPL-53: Add parameter for RunInEdt JUnit5 annotation to take write intent lock. Turn off by default for JUnit5.
GitOrigin-RevId: 9093d3828cf88229b3c6a55ad48ccf2d1d201f47
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b10864ca70
commit
5ff20a1b4e
@@ -26,7 +26,7 @@ import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
public class ClsResolveTest {
|
||||
@RegisterExtension
|
||||
public TempDirectoryExtension tempDir = new TempDirectoryExtension();
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class ExcludePatternsInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.EnumSource
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class OrderEntryGraphTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class OutputDirectoriesInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class PackageIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class UnloadedModulesInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.intellij.testFramework.junit5.RunInEdt
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class PsiJavaModuleModificationTrackerTest : LightJavaCodeInsightFixtureTestCase5() {
|
||||
@Test
|
||||
fun changeInPsiModuleInfo() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class KotlinJUnit5AcceptanceTest : LightJavaCodeInsightFixtureTestCase5() {
|
||||
@BeforeEach
|
||||
internal fun setUp() {
|
||||
|
||||
@@ -35,6 +35,10 @@ class RwLockHolder(writeThread: Thread) {
|
||||
lock.writeIntentUnlock()
|
||||
}
|
||||
|
||||
fun isWriteIntentLocked(): Boolean {
|
||||
return lock.isWriteThread && (lock.isWriteIntentLocked || lock.isWriteAcquired)
|
||||
}
|
||||
|
||||
fun runWithoutImplicitRead(runnable: Runnable) {
|
||||
if (isImplicitReadOnEDTDisabled) {
|
||||
runnable.run()
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class ContentRootWithExcludedPatternsInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.io.File
|
||||
import kotlin.io.path.pathString
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class IteratingContentUnderExcludedTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -31,7 +31,7 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
abstract class LibraryInProjectFileIndexTestCase {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.junit.jupiter.api.extension.RegisterExtension
|
||||
import kotlin.test.assertFalse
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class ModuleRootsInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class NestedModuleAndLibraryRootsInProjectFileIndex {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class NestedModuleRootsInProjectFileIndex {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.nio.file.Path
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class NoIteratingUnderExcludedRootsTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class SdkInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class SyntheticLibraryInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class UpdatingProjectFileIndexOnModuleRootFileModificationsTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class NonRecursiveWorkspaceFileSetTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class WorkspaceFileIndexContributorDynamicRegistrationTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class EdtTestUtil {
|
||||
}
|
||||
|
||||
Ref<T> exception = new Ref<>();
|
||||
Runnable r = writeIntent ?
|
||||
Runnable r = writeIntent && app == null ?
|
||||
() -> {
|
||||
try {
|
||||
setupEventQueue();
|
||||
@@ -95,7 +95,7 @@ public final class EdtTestUtil {
|
||||
}
|
||||
};
|
||||
|
||||
if (app != null) {
|
||||
if (app != null && writeIntent) {
|
||||
app.invokeAndWait(r);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -10,19 +10,38 @@ import java.lang.annotation.Inherited
|
||||
* Instructs the framework to run methods in EDT.
|
||||
* If [allMethods] is set to `true` (default), then all test class methods will be run in EDT, including lifecycle methods.
|
||||
* If [allMethods] is set to `false`, then methods annotated with [RunMethodInEdt] will be run in EDT.
|
||||
* If [writeIntent] is set to `true`, then all test methods will be run with Write Intent Lock by default.
|
||||
* If [writeIntent] is set to `false` (default), then all test methods will be run without Write Intent Lock by default.
|
||||
*/
|
||||
@TestOnly
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Inherited
|
||||
@ExtendWith(EdtInterceptorExtension::class)
|
||||
annotation class RunInEdt(val allMethods: Boolean = true)
|
||||
annotation class RunInEdt(val allMethods: Boolean = true, val writeIntent: Boolean = false)
|
||||
|
||||
/**
|
||||
* Instructs the framework to run a single method in EDT. [RunInEdt] is required on the class level for this annotation to be picked up.
|
||||
* If [writeIntent] is set to [WriteIntentMode.True], then test method will be run with Write Intent Lock.
|
||||
* If [writeIntent] is set to [WriteIntentMode.False], then test method will be run without Write Intent Lock.
|
||||
* If [writeIntent] is set to [WriteIntentMode.Default] (default), then Write Intent Lock is controlled by [RunInEdt.writeIntent].
|
||||
*/
|
||||
@TestOnly
|
||||
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION)
|
||||
annotation class RunMethodInEdt
|
||||
annotation class RunMethodInEdt(val writeIntent: WriteIntentMode = WriteIntentMode.Default) {
|
||||
/**
|
||||
* Enumeration class that represents the mode for write intent.
|
||||
*
|
||||
* The WriteIntentMode enum class provides three possible modes:
|
||||
* - True: Indicates that test must be run under Write Intent Lock.
|
||||
* - False: Indicates that test must be run without Write Intent Lock.
|
||||
* - Default: Indicates that the write intent lock is controlled by the parent annotation (see [RunInEdt]).
|
||||
*
|
||||
* This class is annotated with the @TestOnly annotation, indicating that it is intended
|
||||
* for testing purposes only.
|
||||
*/
|
||||
@TestOnly
|
||||
enum class WriteIntentMode { True, False, Default }
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects a test [disposable][com.intellij.openapi.Disposable] to a field or a parameter in a test.
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.testFramework.junit5.impl
|
||||
|
||||
import com.intellij.testFramework.junit5.RunInEdt
|
||||
import com.intellij.testFramework.junit5.RunMethodInEdt
|
||||
import com.intellij.testFramework.junit5.RunMethodInEdt.WriteIntentMode
|
||||
import com.intellij.testFramework.runInEdtAndGet
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.junit.jupiter.api.extension.DynamicTestInvocationContext
|
||||
@@ -64,7 +65,9 @@ internal class EdtInterceptorExtension : InvocationInterceptor {
|
||||
): T {
|
||||
if (shouldIntercept(invocationContext)) {
|
||||
extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(testFactoryWasInterceptedKey, true)
|
||||
return intercept(invocation)
|
||||
val writeIntent = getWriteIntent(invocationContext)
|
||||
extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).put(testFactoryNeedsWriteIntentKey, writeIntent)
|
||||
return intercept(invocation, writeIntent)
|
||||
}
|
||||
else {
|
||||
return invocation.proceed()
|
||||
@@ -77,7 +80,8 @@ internal class EdtInterceptorExtension : InvocationInterceptor {
|
||||
extensionContext: ExtensionContext,
|
||||
) {
|
||||
if (extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).get(testFactoryWasInterceptedKey) == true) {
|
||||
intercept(invocation)
|
||||
val writeIntent = extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).get(testFactoryNeedsWriteIntentKey) as Boolean
|
||||
intercept(invocation, writeIntent)
|
||||
}
|
||||
else {
|
||||
invocation.proceed()
|
||||
@@ -104,10 +108,11 @@ internal class EdtInterceptorExtension : InvocationInterceptor {
|
||||
private companion object {
|
||||
|
||||
const val testFactoryWasInterceptedKey = "test factory was intercepted"
|
||||
const val testFactoryNeedsWriteIntentKey = "test factory need write intent"
|
||||
|
||||
fun <T> intercept(invocation: Invocation<T>, invocationContext: ReflectiveInvocationContext<*>): T {
|
||||
if (shouldIntercept(invocationContext)) {
|
||||
return intercept(invocation)
|
||||
return intercept(invocation, getWriteIntent(invocationContext))
|
||||
}
|
||||
else {
|
||||
return invocation.proceed()
|
||||
@@ -119,8 +124,23 @@ internal class EdtInterceptorExtension : InvocationInterceptor {
|
||||
return runInEdt.allMethods || AnnotationSupport.findAnnotation(invocationContext.executable, RunMethodInEdt::class.java).isPresent
|
||||
}
|
||||
|
||||
fun <T> intercept(invocation: Invocation<T>): T {
|
||||
return runInEdtAndGet {
|
||||
fun getWriteIntent(invocationContext: ReflectiveInvocationContext<*>): Boolean {
|
||||
val runInEdt = AnnotationSupport.findAnnotation(invocationContext.targetClass, RunInEdt::class.java).get()
|
||||
val runMethodInEdtOpt = AnnotationSupport.findAnnotation(invocationContext.executable, RunMethodInEdt::class.java)
|
||||
if (runMethodInEdtOpt.isEmpty) {
|
||||
return runInEdt.writeIntent
|
||||
}
|
||||
else {
|
||||
when (runMethodInEdtOpt.get().writeIntent) {
|
||||
WriteIntentMode.True -> return true
|
||||
WriteIntentMode.False -> return false
|
||||
WriteIntentMode.Default -> return runInEdt.writeIntent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> intercept(invocation: Invocation<T>, writeIntent: Boolean): T {
|
||||
return runInEdtAndGet(writeIntent) {
|
||||
invocation.proceed()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.testFramework.junit5.showcase;
|
||||
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.testFramework.junit5.RunInEdt;
|
||||
import com.intellij.testFramework.junit5.RunMethodInEdt;
|
||||
import com.intellij.util.ui.EDT;
|
||||
@@ -115,23 +116,27 @@ final class JUnit5RunInEdtTest {
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
MethodLevelAnnotationTest() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,6 +149,7 @@ final class JUnit5RunInEdtTest {
|
||||
@ExtendWith(EmptyTestTemplateInvocationContextProvider.class)
|
||||
void testTemplate() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@@ -152,6 +158,7 @@ final class JUnit5RunInEdtTest {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
return List.of(DynamicTest.dynamicTest("dynamic test", () -> {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -159,12 +166,219 @@ final class JUnit5RunInEdtTest {
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
@RunInEdt(allMethods = false, writeIntent = true) // required to make the extension able to handle lifecycle methods
|
||||
static final class MethodLevelAnnotationTestWithDefaultWriteIntent {
|
||||
|
||||
@RunMethodInEdt
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
MethodLevelAnnotationTestWithDefaultWriteIntent() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodUnannotated() {
|
||||
Assertions.assertFalse(EDT.isCurrentThreadEdt());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@TestTemplate
|
||||
@ExtendWith(EmptyTestTemplateInvocationContextProvider.class)
|
||||
void testTemplate() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@TestFactory
|
||||
List<DynamicTest> testFactory() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
return List.of(DynamicTest.dynamicTest("dynamic test", () -> {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}));
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
@RunInEdt(allMethods = false) // required to make the extension able to handle lifecycle methods
|
||||
static final class MethodLevelAnnotationTestWithPerMethodWriteIntent {
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
MethodLevelAnnotationTestWithPerMethodWriteIntent() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodUnannotated() {
|
||||
Assertions.assertFalse(EDT.isCurrentThreadEdt());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@TestTemplate
|
||||
@ExtendWith(EmptyTestTemplateInvocationContextProvider.class)
|
||||
void testTemplate() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@TestFactory
|
||||
List<DynamicTest> testFactory() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
return List.of(DynamicTest.dynamicTest("dynamic test", () -> {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}));
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.True)
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RunInEdt(allMethods = false, writeIntent = true) // required to make the extension able to handle lifecycle methods
|
||||
static final class MethodLevelAnnotationTestWithoutPerMethodWriteIntent {
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
MethodLevelAnnotationTestWithoutPerMethodWriteIntent() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodUnannotated() {
|
||||
Assertions.assertFalse(EDT.isCurrentThreadEdt());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@TestTemplate
|
||||
@ExtendWith(EmptyTestTemplateInvocationContextProvider.class)
|
||||
void testTemplate() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@TestFactory
|
||||
List<DynamicTest> testFactory() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
return List.of(DynamicTest.dynamicTest("dynamic test", () -> {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}));
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@RunMethodInEdt(writeIntent = RunMethodInEdt.WriteIntentMode.False)
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,26 +388,31 @@ final class JUnit5RunInEdtTest {
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
ClassLevelAnnotationTest() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@ExtendWith(EmptyTestTemplateInvocationContextProvider.class)
|
||||
void testTemplate() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
@@ -201,17 +420,75 @@ final class JUnit5RunInEdtTest {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
return List.of(DynamicTest.dynamicTest("dynamic test", () -> {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
@RunInEdt(writeIntent = true)
|
||||
static final class ClassLevelAnnotationTestWithGlobalWriteIntent {
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
ClassLevelAnnotationTestWithGlobalWriteIntent() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@ExtendWith(EmptyTestTemplateInvocationContextProvider.class)
|
||||
void testTemplate() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
List<DynamicTest> testFactory() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
return List.of(DynamicTest.dynamicTest("dynamic test", () -> {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertTrue(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +501,7 @@ final class JUnit5RunInEdtTest {
|
||||
@Test
|
||||
void testMethod() {
|
||||
Assertions.assertTrue(EDT.isCurrentThreadEdt());
|
||||
Assertions.assertFalse(IdeEventQueue.getInstance().getRwLockHolder().isWriteIntentLocked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.ValueSource
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@RunInEdt
|
||||
@TestApplication
|
||||
@RunInEdt(writeIntent = true)
|
||||
class EntitiesOrphanageTest {
|
||||
|
||||
@JvmField
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
class WorkspaceModelPerformanceTest {
|
||||
companion object {
|
||||
@RegisterExtension
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.intellij.testFramework.junit5.RunInEdt;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
@RunInEdt
|
||||
@RunInEdt(writeIntent = true)
|
||||
abstract class JUnit5CodeInsightTest {
|
||||
protected JavaCodeInsightTestFixture myFixture;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.nio.file.Path
|
||||
import javax.swing.JComponent
|
||||
|
||||
@SkipInHeadlessEnvironment
|
||||
@RunInEdt(allMethods = false)
|
||||
@RunInEdt(allMethods = false, writeIntent = true)
|
||||
class MarkdownEditorCreationTest {
|
||||
@TestDisposable
|
||||
lateinit var disposable: Disposable
|
||||
|
||||
Reference in New Issue
Block a user