File tree 2 files changed +37
-1
lines changed
src/javaConsumersTest/java
2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,15 @@ sourceSets {
134
134
implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion " )
135
135
}
136
136
}
137
+
138
+ create(" javaConsumersTest" ) {
139
+ compileClasspath + = sourceSets.test.get().runtimeClasspath
140
+ runtimeClasspath + = sourceSets.test.get().runtimeClasspath
141
+
142
+ dependencies {
143
+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion " )
144
+ }
145
+ }
137
146
}
138
147
139
148
kotlin {
@@ -199,16 +208,23 @@ tasks {
199
208
classpath = sourceSet.runtimeClasspath
200
209
}
201
210
211
+ create<Test >(" javaConsumersTest" ) {
212
+ val sourceSet = sourceSets[name]
213
+ testClassesDirs = sourceSet.output.classesDirs
214
+ classpath = sourceSet.runtimeClasspath
215
+ }
216
+
202
217
check {
203
218
dependsOn(
204
219
" jvmCoreTest" ,
205
220
" debugDynamicAgentTest" ,
206
221
" mavenTest" ,
207
222
" debugAgentTest" ,
208
223
" coreAgentTest" ,
224
+ " javaConsumersTest" ,
209
225
" :jpmsTest:check" ,
210
226
" smokeTest:build" ,
211
- " java8Test:check"
227
+ " java8Test:check" ,
212
228
)
213
229
}
214
230
Original file line number Diff line number Diff line change
1
+ import kotlinx .coroutines .BuildersKt ;
2
+ import kotlinx .coroutines .Dispatchers ;
3
+ import org .junit .Test ;
4
+
5
+ public class RunBlockingJavaTest {
6
+ Boolean entered = false ;
7
+
8
+ /** This code will not compile if `runBlocking` doesn't declare `@Throws(InterruptedException::class)` */
9
+ @ Test
10
+ public void testRunBlocking () {
11
+ try {
12
+ BuildersKt .runBlocking (Dispatchers .getIO (), (scope , continuation ) -> {
13
+ entered = true ;
14
+ return null ;
15
+ });
16
+ } catch (InterruptedException e ) {
17
+ }
18
+ assert entered ;
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments