-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ide starter] IJ-CR-118555 Correct waiting till Maven is able to dest…
…roy daemon GitOrigin-RevId: 5f2b98239620446d1c000fbd6307add34ec424d2
- Loading branch information
1 parent
e9acc7b
commit 5da252c
Showing
18 changed files
with
344 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ools.ide.starter.junit5/testSrc/com/intellij/ide/starter/junit5/FiringNestedEventsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.intellij.ide.starter.junit5 | ||
|
||
import com.intellij.ide.starter.bus.Signal | ||
import com.intellij.ide.starter.bus.StarterBus | ||
import io.kotest.assertions.withClue | ||
import io.kotest.matchers.booleans.shouldBeTrue | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Test | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
class FiringNestedEventsTest { | ||
@AfterEach | ||
fun afterEach() { | ||
StarterBus.LISTENER.unsubscribe() | ||
} | ||
|
||
class FirstEvent : Signal() { | ||
init { | ||
StarterBus.postAndWaitProcessing(SecondEvent(), timeout = 2.seconds).shouldBeTrue() | ||
} | ||
} | ||
|
||
class SecondEvent : Signal() | ||
|
||
@Test | ||
fun `firing nested events should work`() { | ||
val firstSubscriberProcessedEvent = AtomicBoolean(false) | ||
val secondSubscriberProcessedEvent = AtomicBoolean(false) | ||
|
||
StarterBus | ||
.subscribe(this) { _: FirstEvent -> | ||
firstSubscriberProcessedEvent.set(true) | ||
} | ||
.subscribe(this) { _: SecondEvent -> | ||
secondSubscriberProcessedEvent.set(true) | ||
} | ||
|
||
StarterBus.postAndWaitProcessing(FirstEvent(), timeout = 2.seconds).shouldBeTrue() | ||
|
||
withClue("Processing nested events should not lead to deadlock") { | ||
firstSubscriberProcessedEvent.get().shouldBeTrue() | ||
secondSubscriberProcessedEvent.get().shouldBeTrue() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...ols.ide.starter.junit5/testSrc/com/intellij/ide/starter/junit5/SubscribingOnlyOnceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.intellij.ide.starter.junit5 | ||
|
||
import com.intellij.ide.starter.bus.Signal | ||
import com.intellij.ide.starter.bus.StarterBus | ||
import io.kotest.assertions.withClue | ||
import io.kotest.matchers.shouldBe | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Test | ||
import java.util.concurrent.atomic.AtomicInteger | ||
|
||
|
||
class SubscribingOnlyOnceTest { | ||
@AfterEach | ||
fun afterEach() { | ||
StarterBus.LISTENER.unsubscribe() | ||
} | ||
|
||
@Test | ||
fun `multiple subscription should not work if subscribed only once`() { | ||
val obj = Any() | ||
|
||
val eventProcessedTimes = AtomicInteger() | ||
val secondProcessedTimes = AtomicInteger() | ||
|
||
StarterBus | ||
.subscribeOnlyOnce(this) { _: Signal -> | ||
eventProcessedTimes.incrementAndGet() | ||
} | ||
.subscribeOnlyOnce(this) { _: Signal -> | ||
eventProcessedTimes.incrementAndGet() | ||
} | ||
.subscribeOnlyOnce(obj) { _: Signal -> | ||
secondProcessedTimes.incrementAndGet() | ||
} | ||
.subscribeOnlyOnce(obj) { _: Signal -> | ||
secondProcessedTimes.incrementAndGet() | ||
} | ||
|
||
StarterBus.postAsync(Signal()) | ||
|
||
withClue("Multiple subscription should not work if subscribed only once") { | ||
eventProcessedTimes.get().shouldBe(1) | ||
secondProcessedTimes.get().shouldBe(1) | ||
} | ||
|
||
eventProcessedTimes.set(0) | ||
secondProcessedTimes.set(0) | ||
|
||
StarterBus.postAndWaitProcessing(Signal()) | ||
|
||
withClue("Multiple subscription should not work if subscribed only once") { | ||
eventProcessedTimes.get().shouldBe(1) | ||
secondProcessedTimes.get().shouldBe(1) | ||
} | ||
} | ||
|
||
@Test | ||
fun `multiple subscription should work by default`() { | ||
val obj = Any() | ||
|
||
val eventProcessedTimes = AtomicInteger() | ||
val secondProcessedTimes = AtomicInteger() | ||
|
||
StarterBus | ||
.subscribe(this) { event: Signal -> | ||
eventProcessedTimes.incrementAndGet() | ||
} | ||
.subscribe(this) { event: Signal -> | ||
eventProcessedTimes.incrementAndGet() | ||
} | ||
.subscribe(this) { event: Signal -> | ||
eventProcessedTimes.incrementAndGet() | ||
} | ||
.subscribe(obj) { _: Signal -> | ||
secondProcessedTimes.incrementAndGet() | ||
} | ||
.subscribe(obj) { _: Signal -> | ||
secondProcessedTimes.incrementAndGet() | ||
} | ||
|
||
StarterBus.postAsync(Signal()) | ||
|
||
withClue("Multiple subscription should work by default") { | ||
eventProcessedTimes.get().shouldBe(3) | ||
secondProcessedTimes.get().shouldBe(2) | ||
} | ||
|
||
eventProcessedTimes.set(0) | ||
secondProcessedTimes.set(0) | ||
|
||
StarterBus.postAndWaitProcessing(Signal()) | ||
|
||
withClue("Multiple subscription should work by default") { | ||
eventProcessedTimes.get().shouldBe(3) | ||
secondProcessedTimes.get().shouldBe(2) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
intellij.tools.ide.starter/src/com/intellij/ide/starter/bus/Event.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.