• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 package kotlinx.coroutines
6 
7 import org.junit.*
8 import java.io.*
9 
10 
11 @Suppress("BlockingMethodInNonBlockingContext")
12 class JobCancellationExceptionSerializerTest : TestBase() {
13 
14     @Test
<lambda>null15     fun testSerialization() = runTest {
16         try {
17             coroutineScope {
18                 expect(1)
19 
20                 launch {
21                     expect(2)
22                     try {
23                         hang {}
24                     } catch (e: CancellationException) {
25                         throw RuntimeException("RE2", e)
26                     }
27                 }
28 
29                 launch {
30                     expect(3)
31                     throw RuntimeException("RE1")
32                 }
33             }
34         } catch (e: Throwable) {
35             // Should not fail
36             ObjectOutputStream(ByteArrayOutputStream()).use {
37                 it.writeObject(e)
38             }
39             finish(4)
40         }
41     }
42 }
43