-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3: Should not reinitialize Resources parameter for beforeAll …
…or for static method
- Loading branch information
Showing
8 changed files
with
125 additions
and
33 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
package com.asarkar.grpc.test | ||
|
||
import io.grpc.inprocess.InProcessChannelBuilder | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.mockito.Mockito | ||
import kotlin.random.Random | ||
|
||
@ExtendWith(GrpcCleanupExtension::class) | ||
class ExampleTestCase2 { | ||
private lateinit var resources: Resources | ||
private val setOfResources: Set<Resources?> = mutableSetOf() | ||
private val setOfResources: MutableSet<Resources?> = mutableSetOf() | ||
private val set = Mockito.spy(setOfResources) | ||
|
||
@Test | ||
fun test1() { | ||
setOfResources.plus(resources) | ||
resources.register(randomChannel()) | ||
assertThat(setOfResources.add(resources)).isTrue() | ||
} | ||
|
||
@Test | ||
fun test2() { | ||
setOfResources.plus(resources) | ||
resources.register(randomChannel()) | ||
assertThat(setOfResources.add(resources)).isTrue() | ||
} | ||
|
||
@Test | ||
fun test3() { | ||
setOfResources.plus(resources) | ||
resources.register(randomChannel()) | ||
assertThat(setOfResources.add(resources)).isTrue() | ||
} | ||
|
||
private fun randomChannel() = InProcessChannelBuilder | ||
.forName((1..4).map { ('a' + Random.nextInt(0, 26)) }.joinToString("")) | ||
.build() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.asarkar.grpc.test | ||
|
||
import io.grpc.ManagedChannel | ||
import io.grpc.inprocess.InProcessChannelBuilder | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.TestInstance | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.mockito.Mockito | ||
import kotlin.random.Random | ||
|
||
@ExtendWith(GrpcCleanupExtension::class) | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class ExampleTestCase9 { | ||
private lateinit var channel: ManagedChannel | ||
private val setOfResources: MutableSet<Resources?> = mutableSetOf() | ||
private val set = Mockito.spy(setOfResources) | ||
|
||
@BeforeAll | ||
fun beforeAll(resources: Resources) { | ||
channel = randomChannel() | ||
resources.register(channel) | ||
assertThat(setOfResources.add(resources)).isTrue() | ||
} | ||
|
||
@Test | ||
fun test1(resources: Resources) { | ||
assertThat(channel.isShutdown).isFalse() | ||
assertThat(channel.isTerminated).isFalse() | ||
resources.register(randomChannel()) | ||
assertThat(setOfResources.add(resources)).isTrue() | ||
} | ||
|
||
@Test | ||
fun test2(resources: Resources) { | ||
assertThat(channel.isShutdown).isFalse() | ||
assertThat(channel.isTerminated).isFalse() | ||
resources.register(randomChannel()) | ||
assertThat(setOfResources.add(resources)).isTrue() | ||
} | ||
|
||
private fun randomChannel() = InProcessChannelBuilder | ||
.forName((1..4).map { ('a' + Random.nextInt(0, 26)) }.joinToString("")) | ||
.build() | ||
} |
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