File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
kotlinx-coroutines-nio/src/test/kotlin/kotlinx/coroutines/experimental/nio Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,13 @@ import java.nio.channels.AsynchronousFileChannel
11
11
import java.nio.channels.AsynchronousServerSocketChannel
12
12
import java.nio.channels.AsynchronousSocketChannel
13
13
import java.nio.file.StandardOpenOption
14
+ import java.util.*
14
15
import kotlin.test.assertEquals
15
16
import kotlin.test.assertTrue
16
17
17
18
class AsyncIOTest {
19
+ val PORT = Random ().nextInt(10000 ) + 10000 // randomize port for this test
20
+
18
21
@Rule
19
22
@JvmField
20
23
val tmpDir = TemporaryFolder ()
@@ -63,7 +66,7 @@ class AsyncIOTest {
63
66
val serverChannel =
64
67
AsynchronousServerSocketChannel
65
68
.open()
66
- .bind(InetSocketAddress (8080 ))
69
+ .bind(InetSocketAddress (PORT ))
67
70
68
71
val c1 = launch(CommonPool ) {
69
72
val client = serverChannel.aAccept()
@@ -80,7 +83,7 @@ class AsyncIOTest {
80
83
val connection =
81
84
AsynchronousSocketChannel .open()
82
85
// async calls
83
- connection.aConnect(InetSocketAddress (" 127.0.0.1" , 8080 ))
86
+ connection.aConnect(InetSocketAddress (" 127.0.0.1" , PORT ))
84
87
connection.aWrite(Charsets .UTF_8 .encode(" OK" ))
85
88
86
89
val buffer = ByteBuffer .allocate(3 )
You can’t perform that action at this time.
0 commit comments